Loading external dll

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Loading external dll

Post by aks » Wed Oct 15, 2008 9:06 am

Hi,

Can i load external dll and use api's of that in my script?

If yes where can i find information on registering the dll to macros?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Oct 15, 2008 9:40 am

If the DLL uses the stdcall convention and requires nothing more complicated than strings and/or numerics, then, yes you can load it and call functions within it. To do so you need to use the following Macro Scheduler functions:

LibLoad
LibFunc
LibFree
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Wed Oct 15, 2008 1:52 pm

Hi,

Thanks that answers my question. I am evaluating macro scheduler 10. I am more interested in the image recognition feature. Is there a help on what are all the commands of macro scheduler i can use for image recognition automation? Can i use waitWindowTitle>winImg.bmp? After this for verification, can i get the text inside the appeared image? Any information on this would be of great help.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Oct 15, 2008 1:53 pm

The best place to get a good grounding on image recognition is probably:
http://www.mjtnet.com/blog/2007/02/20/h ... cognition/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Tue Oct 21, 2008 10:46 am

Hi Marcus,

I tried the following code to use a function in the external dll:

LibLoad>F:\myLib.dll,hnd
LibFunc>hnd,LibRegister,check,ref:MacroEngine,ref:Handle
MessageModal>check
LibFree>hnd

variable check should contain a string. But while running this code i got
"access violation error". I have previously used this dll with another tool so it is completely tested. Please let me know if i am using macro functions right?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Oct 21, 2008 10:53 am

Is the DLL using the stdcall calling convention? What are the parameter types? How many parameters? two? Strings or numbers? ref is used to pass numeric values by reference, but I don't see MacroEngine or Handle set to a numeric value. If you don't need them preset but want to get a value back just use 0:

LibFunc>hnd,LibRegister,check,ref:0,ref:0

Results will be in check, check_1 and check_2

If you can't get it working I would need to see the DLL docs or the DLL source to tell you whether it will work and what you need to do.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Wed Oct 22, 2008 7:06 am

Hi Marcus,

Function defined in the dll is: unsigned int LibRegister(char *handleName, char *handle)

As u see both are character pointers. And return type is int.

Do you see something that i should change?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Oct 22, 2008 7:13 am

Remove the "Ref:" which is for passing numbers by reference. These are char pointers, not numbers, and char pointers are references.

But - what is the calling convention? Is it stdcall?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Wed Oct 22, 2008 11:07 am

Hi Marcus,

I tried the following code:
LibLoad>myLib.dll,hLib
Remark>Registering with framework lib
LibFunc>hLib,LibRegister,rc,MacroEngine,Handle

If i debug the first line macro scheduler message box pops up saying

'Access violation at address 00000015.Read of address 00000015'

And if i place the debugger pointer at the 3rd line, i get the messages
'Unable to load the dll'. Yes dll is using stdcall calling convention and developed using visual studio 6. Also i have placed the dll in system32 folder so i am not giving the complete path.

Thanks for your support

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Oct 22, 2008 11:14 am

Something is wrong if it is crashing when you try to load it. What does the DLL try to do on initialization?

Are you able to send me the DLL and it's documentation (or even source code)? Send to my email address in my sig.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts