Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API for detecting SW application launch...

Status
Not open for further replies.

RawheadRex

Mechanical
Feb 9, 2001
236
I have program (in VB6) that runs as a standalone application but also has the ability to connect to SolidWorks and provide a certain level of integration as well. Users may or may not need to use the application in conjunction with SolidWorks at any given time. I'm in the process of expanding functionality and making it more bullet-proof. I already have the ability to create or connect to any existing SolidWorks object. One thing that I'd like to be able to do, is to have functionality that sits waiting to detect the launch of SolidWorks in Windows (if it isn't currently running) which will fire off a series of events in my program that will attach to the SolidWorks object.

I obviously wasn't paying attention very well the day they taught us that in school. But as I recall this doesn't pose very much of a programming problem. For the life of me I can't seem to track down anything decent in the way of information on detecting Windows Events (which I believe an application launch falls under).

Sorry if this is a bone-headed question but any help or suggestions would be greatly appreciated (pointers to info or code samples especially).

Thanks,
Chris Gervais
Mechanical Designer
American Superconductor
 
Replies continue below

Recommended for you

Target location: Executables under the SolidWorks Icon on the desktop
"J:\ SolidWorks\Executables\StartSolidWorks.exe"

Then in the VB program J:\ SolidWorks\Executables\StartSolidWorks.exe have the following:

Private Sub Form_Load()
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
lPid = Shell("J:\ Executables\CopyFile.exe", vbNormalFocus)
If lPid <> 0 Then
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid) ' Get a handle to the shelled process.
If lHnd <> 0 Then ' If successful, wait for the
lRet = WaitForSingleObject(lHnd, INFINITE) ' application to end.
CloseHandle (lHnd) ' Close the handle.
End If
End If
Dim StartSolidWorks As String
Run Copy Files program & SolidWorks.
StartSolidWorks = Shell(&quot;C:\Program Files\SolidWorks\sldworks.exe&quot;, 1) ' Run Copy Files program & SolidWorks.
Call cmdExit_Click
End Sub


Bradley
 
Bradley,

Thank you very much, this looks pretty good and I believe I understand the general gist of how the code works though I'll need to read up on some of the functions your using to understand fully. But I'm unclear on what CopyFile.exe is and what it is/does. If you would, please walk me through what the purpose of this exe is and how it fits into the code.

Thanks Again,
ChrisG
 
ChrisG,
The functions in StartSolidWorks.exe I do not understand at all. I copied it off some website.
The CopyFiles.exe program copies the macros you have written for SolidWorks, each time a user double clicks the SolidWorks icon. This way, you update all macros to each person’s hard drive. I have removed all the extras from my program to make it easier to understand. Build the following program in VB and save it as J:\ Executables\CopyFile.exe

Private Sub Form_Load()
FileCopy &quot;J:\ SolidWorks\Executables\bomtemp.xls&quot;, _
&quot;C:\Program Files\SolidWorks\lang\english\bomtemp.xls&quot; ' To:
' Ctrl F12 - Title Block program
FileCopy &quot;J:\ SolidWorks\Executables\TitleBlock.swb&quot;, _
&quot;C:\Program Files\SolidWorks\Macros\TitleBlock.swb&quot; ' To:
Unload Me
End
End Sub
* * * * * * * *
This is easy and invisible to users. Once you get the SolidWorks Icon setup, you or the user may not need to touch their machine again. The user will have to program the macro keys, for e.g. Ctrl F12 for TitleBlock.swb macro.
If you have anymore questions please ask.
Bradley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor