working with COM OBJECTS need help with Multiple instances

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
keokio
Posts: 10
Joined: 28 Oct 2019, 23:03

working with COM OBJECTS need help with Multiple instances

Post by keokio » 21 May 2022, 18:28

Ok so I work 3d CAM software ESPRITCAM. It uses Com OBJ very similar to Excel, and has built in Macro editor. I want to call on objects using autohotkey and so far I have been successful with these codes:

Code: Select all

TRY oesprit := ComObjCreate("ESPRIT.APPLICATION")
oesprit .VISIBLE := TRUE
msgbox % isobject(oesprit)
oesprit.NEW
I can create an application Espritcam, make it visible, also make sure its an object, and lastly for a test run call on an object to create a new file within the ESPRIT application.
The issue is when I run multiple instances of this program. So now I try to run an object using COMOBJACTIVE, to call on the active instance of ESPRIT.

Code: Select all

try oesprit:= ComObjActive("ESPRIT.APPLICATION")
msgbox % isobject(oesprit)
when I run this, it does not recognize the object and returns a '0'. When I'm running multiple instances of ESPRIT, I need to run the objects on the current active ESPRIT program or better yet find the specific pointer to each instance of ESPRIT and run objects. I'm sure it has something to do with finding program ID, process ID, or HWND. Just not sure how to go about this. Any help would be greatly appreciated. Thanks

lexikos
Posts: 9607
Joined: 30 Sep 2013, 04:07
Contact:

Re: working with COM OBJECTS need help with Multiple instances

Post by lexikos » 21 May 2022, 18:38

This will only work if the application registers its automation object as the active object for that class.

You can try using GetActiveObjects instead. Run the example in that topic to see what objects are running right now.

Post Reply

Return to “Ask for Help (v1)”