Image Recognition Library

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

Image Recognition Library

Post by guyash2 » Fri Nov 03, 2006 5:15 pm

Hello,
I am trying to program a macro and I can't succeed in doing that in spite of the fact that I have read all the help file.
I have the newest version of macro scheduler- 8.1
I have downloaded the Image Recognition Library files and put it in the directory where the software is installed. I want to "Find occurrences of needle bitmap in haystack bitmap" like the help file says in FindImgPos category. When I try copy the code I get a message "Invalid Numeric Value for MouseMove command."
What should I do? Can anyone detail me more about the form of writing this script?

Thank you.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Nov 03, 2006 5:55 pm

One cause could be trailing spaces.
Make sure that you have removed any trailing spaces that are not really necessary.

But that is just a possibility. May not be the problem. If that does not work, please provide a copy of the script you have written.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

Post by guyash2 » Fri Nov 03, 2006 7:20 pm

Bob Hansen wrote:One cause could be trailing spaces.
Make sure that you have removed any trailing spaces that are not really necessary.

But that is just a possibility. May not be the problem. If that does not work, please provide a copy of the script you have written.
I clicked on edit-->remove trailing spaces and it still doesn't work.
Here is my code:

Code: Select all

Let>imglibDLL=%SCRIPT_DIR%\imglib.dll
LibLoad>imglibDll,imglib

IfFileExists>d:\screen.bmp
       DeleteFile>d:\screen.bmp
EndIf
ScreenCapture>0,0,1024,768,d:\screen.bmp

LibFunc>imglib,FindImgPos,imgs,d:\s.bmp,d:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
       Let>x=imgs_5+x
       Let>y=imgs_6+y
       MouseMove>x,y
       LClick
Endif


d:\s.bmp is a picture of a part in my desktop and when I run this script I am on the desktop.

Thanks.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Nov 03, 2006 7:29 pm

Let>x=imgs_5+x
Let>y=imgs_6+y
MouseMove>x,y
In your posted code you have not previously defined any value for "x" or "y". Therefore when you try to Let>x=imgs_5+x you are setting the value of "x" to the text "imgs_5+x". Same with "y". This would cause an error like "Invalid Numeric Value for MouseMove command."

Hope this helps,
Dick

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri Nov 03, 2006 7:50 pm

Would you please log the file, run it, then post the log file?

If you loaded Image Library in it's default location, then there is the possibility that the imglib.dll is not in %SCRIPT_DIR% and so the dll is not loading at all.

you should always include code to "look before you leap"....here is an example.

Code: Select all

iffileexists>=%SCRIPT_DIR%\imglib.dll
   Let>imglibDLL=%SCRIPT_DIR%\imglib.dll 
   LibLoad>imglibDll,imglib
else>
   mdl>the imglib.dll does not exist in this folder
  goto>End
endif>

IfFileExists>d:\screen.bmp 
   DeleteFile>d:\screen.bmp 
EndIf 
ScreenCapture>0,0,1024,768,d:\screen.bmp 
ife>d:\s.bmp

LibFunc>imglib,FindImgPos,imgs,d:\s.bmp,d:\screen.bmp,20,1,ref:0,ref:0 
If>imgs>0 
   Let>x=imgs_5+x 
   Let>y=imgs_6+y 
   MouseMove>x,y 
   LClick 
Endif
else>
   mdl>the file s.bmp not found
endif>

Label>End


guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

..

Post by guyash2 » Sat Nov 04, 2006 12:27 pm

Thank you two for yor help.
I removed and installed macro scheduler again and then installed again the image library in the same folder of the macro scheduler.
I don't know how to create a log file but when I run your script I get the message "the imglib.dll does not exist in this folder" (it is the message that you wrote in the code and not a message of the software).

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Nov 04, 2006 2:52 pm

You create a log file by using the options in the Macro Properties.

Right click the macro name and left click Macro Properties.There is a tab there to enable logging. Enable logging.

I usually use the log level "Log entry BEFORE running step" It also helps to have your script variables surrounded with % symbols so the log will record the value of the variable at the time it was run.

You can also single step through the script or add a Message Box to see the value of %SCRIPT_DIR% and make sure that is where your file is located.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

Thanks

Post by guyash2 » Sat Nov 04, 2006 5:46 pm

Thank you for explaining me.
Here is the log file for SkunkWorks's code:

Code: Select all

04/11/2006 19:44:39:851 - Started Macro : dsdf
04/11/2006 19:44:39:851 - iffileexists>=C:\Documents and Settings\Administrator\Application Data\Macro Scheduler\imglib.dll
04/11/2006 19:44:39:851 - mdl>the imglib.dll does not exist in this folder
04/11/2006 19:44:41:460 - goto>End
04/11/2006 19:44:41:460 - Finished Macro : dsdf


User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Sat Nov 04, 2006 9:55 pm

Your log file CLEARLY shows that the imglib.dll does not exist in the directory. do a quick search of your system and tell us where you find imglib.dll

when you find it, move it to your %SCRIPT_DIR% ...which is probably c:\program files\mjt net ltd\Macro Scheduler

Then run the script again and post your log file.

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

..

Post by guyash2 » Sun Nov 05, 2006 6:02 am

I have ran a full system scan and I found the file imglib.dll just once.
It is located in the folder D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler.

I have two versions of Macro Scheduler- 7.2 and 8.1.
I usually use 7.2 but because it doesn't have the option of image recognition I was this time the 8.1 version. I changed the name of the folder from "MJT Net Ltd" to "MJT Net Ltd 8.1".

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Sun Nov 05, 2006 2:21 pm

So then, when you load the imglib.dll, name the path explicitly. Do not use %SCRIPT_DIR% as the path.


Let>imglibDLL=D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll\imglib.dll
LibLoad>imglibDll,imglib

then run the script, create a log, and post that log.

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

Thank you

Post by guyash2 » Sun Nov 05, 2006 5:18 pm

I realize now and I changed the %SCRIPT DIR% to the folder, as you said.
Now I have anither problem, that might be rekated to what JRL has said.
I get the message: "Invalid Numeric Value for MouseMove command.".
Here is my new code:

Code: Select all

iffileexists>D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll
   Let>imglibDLL=D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll\imglib.dll
   LibLoad>imglibDll,imglib
else>
   mdl>the imglib.dll does not exist in this folder
  goto>End
endif>

IfFileExists>d:\screen.bmp
   DeleteFile>d:\screen.bmp
EndIf
ScreenCapture>0,0,1024,768,d:\screen.bmp
ife>d:\s.bmp

LibFunc>imglib,FindImgPos,imgs,d:\s.bmp,d:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
   Let>x=imgs_5+x
   Let>y=imgs_6+y
   MouseMove>x,y
   LClick
Endif
else>
   mdl>the file s.bmp not found
endif>

Label>End



Here is the log file:

Code: Select all

05/11/2006 19:18:15:156 - Started Macro : dsdf
05/11/2006 19:18:15:156 - iffileexists>D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll
05/11/2006 19:18:15:156 - Let>imglibDLL=D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll\imglib.dll
05/11/2006 19:18:15:156 - LibLoad>imglibDll,imglib
05/11/2006 19:18:15:156 - else>
05/11/2006 19:18:15:156 - 
05/11/2006 19:18:15:156 - IfFileExists>d:\screen.bmp
05/11/2006 19:18:15:156 - DeleteFile>d:\screen.bmp
05/11/2006 19:18:15:156 - EndIf
05/11/2006 19:18:15:171 - ScreenCapture>0,0,1024,768,d:\screen.bmp
05/11/2006 19:18:15:281 - ife>d:\s.bmp
05/11/2006 19:18:15:281 - 
05/11/2006 19:18:15:281 - LibFunc>imglib,FindImgPos,imgs,d:\s.bmp,d:\screen.bmp,20,1,ref:0,ref:0
05/11/2006 19:18:15:296 - If>imgs>0
05/11/2006 19:18:15:296 - Let>x=imgs_5+x
05/11/2006 19:18:15:296 - Let>y=imgs_6+y
05/11/2006 19:18:15:296 - MouseMove>x,y
05/11/2006 19:18:16:859 - LClick
05/11/2006 19:18:16:953 - Endif
05/11/2006 19:18:16:953 - else>
05/11/2006 19:18:16:953 - 
05/11/2006 19:18:16:953 - Label>End
05/11/2006 19:18:16:968 - Finished Macro : dsdf



User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Sun Nov 05, 2006 7:30 pm

I see where I made a mistake in the code sample.

Please note that imglib.dll should only be written ONCE in the path to the file.

this:

Let>imglibDLL=D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll\imglib.dll

should be:

Let>imglibDLL=D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll


That is probably causing the error. The DLL just wasn't loading

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

I have done that

Post by guyash2 » Sun Nov 05, 2006 8:52 pm

Now here is ny code:

Code: Select all

iffileexists>D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll
   Let>imglibDLL=D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll
   LibLoad>imglibDll,imglib
else>
   mdl>the imglib.dll does not exist in this folder
  goto>End
endif>

IfFileExists>d:\screen.bmp
   DeleteFile>d:\screen.bmp
EndIf
ScreenCapture>0,0,1024,768,d:\screen.bmp
ife>d:\s.bmp

LibFunc>imglib,FindImgPos,imgs,d:\s.bmp,d:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
   Let>x=imgs_5+x
   Let>y=imgs_6+y
   MouseMove>x,y
   LClick
Endif
else>
   mdl>the file s.bmp not found
endif>

Label>End

But I still have the same problem, the message: ""Invalid Numeric Value for MouseMove command.".
I see now a difference by the time the code takes to get the message. Before erasing the second imglib.dll it took the code less time to give the message than after I have changed it.
Here is the log file:

Code: Select all

05/11/2006 22:49:55:531 - Started Macro : dsdf
05/11/2006 22:49:55:531 - iffileexists>D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll
05/11/2006 22:49:55:531 - Let>imglibDLL=D:\Program Files\MJT Net Ltd 8.1\Macro Scheduler\imglib.dll
05/11/2006 22:49:55:531 - LibLoad>imglibDll,imglib
05/11/2006 22:49:55:531 - else>
05/11/2006 22:49:55:531 - 
05/11/2006 22:49:55:531 - IfFileExists>d:\screen.bmp
05/11/2006 22:49:55:531 - DeleteFile>d:\screen.bmp
05/11/2006 22:49:55:531 - EndIf
05/11/2006 22:49:55:531 - ScreenCapture>0,0,1024,768,d:\screen.bmp
05/11/2006 22:49:55:656 - ife>d:\s.bmp
05/11/2006 22:49:55:671 - 
05/11/2006 22:49:55:671 - LibFunc>imglib,FindImgPos,imgs,d:\s.bmp,d:\screen.bmp,20,1,ref:0,ref:0
05/11/2006 22:49:56:906 - If>imgs>0
05/11/2006 22:49:56:906 - Let>x=imgs_5+x
05/11/2006 22:49:56:906 - Let>y=imgs_6+y
05/11/2006 22:49:56:906 - MouseMove>x,y
05/11/2006 22:49:59:656 - LClick
05/11/2006 22:49:59:656 - Endif
05/11/2006 22:49:59:656 - else>
05/11/2006 22:49:59:656 - 
05/11/2006 22:49:59:656 - Label>End
05/11/2006 22:49:59:656 - Finished Macro : dsdf



User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Nov 05, 2006 8:52 pm

I believe that you will still be having a problem with MouseMove.

See the information from JRL earlier.
You are making x and y equal to text values, not to numbers.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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