Macro Image Library

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Macro Image Library

Post by adivarup » Tue Mar 28, 2006 5:46 am

Hello....

Are there more instructions apart from the ImgLib help file? There is a Submit Icon on this webpage written in Java Script. I copied the image icon that says Submit, but have no clue how to tell my script what to do with this file ( I just want it to be executed so the post I add is submitted).

Thanks for any help!!
________
WEEDMAPS
Last edited by adivarup on Sat Aug 13, 2011 3:07 pm, edited 1 time in total.

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 Mar 28, 2006 7:28 am

Have you looked at the examples in the help file and with the image recognition library? They show you exactly what you want to do. You need to use the Capture Tool to capture the icon from the screen to a bitmap file. You then specify that file and a full screen grab (taken with ScreenCapture) in the FindImgPos function. There is an example that does just this with the library.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Tue Mar 28, 2006 6:39 pm

I did look. I will work on it again now. But I just found it hard to understand. I am new to this. Thanks for all your assistance.
________
buy herbalaire
Last edited by adivarup on Wed Feb 02, 2011 12:35 pm, edited 1 time in total.

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Tue Mar 28, 2006 7:55 pm

Hello,

I am playing with this code

LibLoad>imglibDll,imglib

//Focus Google
SetFocus>Google - Microsoft Internet Explorer
Wait>1
//Get bounds of window
GetActiveWindow>title,X,Y,W,H

//Capture the screen to a bitmap
IfFileExists>C:\screen.bmp
DeleteFile>C:\screen.bmp
EndIf
ScreenCapture>X,Y,W,H,C:\screen.bmp

LibFunc>imglib,FindImgPos,imgs,C:\googlebutton.bmp,C:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
//click on button
//remember that x,y returned is relative the image and since we didn't use the
//full screen we will need add top left offset to get screen coordinates
Let>x=imgs_5+x
Let>y=imgs_6+y
MouseMove>x,y
LClick
Endif

LibFree>imglib



I captured the screen for google and saved it as screen.bmp and placed it in my C: root
I also captured just the submit button in google and saved it as googlebutton.bmp in my c:

No I run a step by step just to see if it will click the submit button and on this line

ScreenCapture>X,Y,W,H,C:\screen.bmp

I get an error "The parameter is not correct".

Please tell me what step i am missing.

Thank you!
________
easy vape review
Last edited by adivarup on Wed Feb 02, 2011 12:36 pm, edited 1 time in total.

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Tue Mar 28, 2006 9:32 pm

Can anyone assist? I am afraid these instructions are not clear to me.
________
marijuana joint
Last edited by adivarup on Wed Feb 02, 2011 12:36 pm, edited 1 time in total.

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Tue Mar 28, 2006 11:25 pm

This is killing me.. It seems like it is working, but only if the window is in a absolute position. This wont work, as the window may open up in a differnt part of the screen... Here is what I have..

Let>imglibDLL=%SCRIPT_DIR%\imglib.dll
LibLoad>imglibDll,imglib
MouseMove>0,0
//Focus Google
SetFocus>Google - Microsoft Internet Explorer
Wait>1
//Get bounds of window
GetActiveWindow>title,X,Y,W,H

//Capture the screen to a bitmap
IfFileExists>d:\screen.bmp
DeleteFile>c:\screen.bmp
EndIf
ScreenCapture>X,Y,1500,600,c:\screen.bmp

LibFunc>imglib,FindImgPos,imgs,c:\googlebutton.bmp,c:\screen.bmp,20,1,ref:0,ref:0

MouseMove>1000,360
LClick
Endif

LibFree>imglib


Any suggestions?
________
digital vaporizer
Last edited by adivarup on Wed Feb 02, 2011 12:36 pm, edited 1 time in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Mar 29, 2006 12:31 am

LibFunc>imglib,FindImgPos,imgs,c:\googlebutton.bmp,c:\screen.bmp,20,1,ref:0,ref:0

MouseMove>1000,360
LClick
Endif

I don't have MS/image library on this PC so I can't give you the whole answer but here's a clue that should help you figure it out.

You are correctly using FindImgPos to find the position of the image(button), but then you are ignoring the result and doing a MouseMove to the fixed coordinates 1000,300. What you should be doing is a MouseMove to where FindImagePos is finding the image.

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Wed Mar 29, 2006 12:48 am

Thanks for your response..

in the example, it is written:


ScreenCapture>X,Y,W,H,d:\screen.bmp

LibFunc>imglib,FindImgPos,imgs,d:\googlebutton.bmp,d:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
//click on button
//remember that x,y returned is relative the image and since we didn't use the
//full screen we will need add top left offset to get screen coordinates
Let>x=imgs_5+x
Let>y=imgs_6+y
MouseMove>x,y
LClick
Endif


I use this, but nothing is clicked on, so I changed the MouseMove position.

here is the full script as it is posted in the help file. I really am not sure what to do here.

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

//Focus Google
SetFocus>Google - Microsoft Internet Explorer
Wait>1
//Get bounds of window
GetActiveWindow>title,X,Y,W,H

//Capture the screen to a bitmap
IfFileExists>d:\screen.bmp
DeleteFile>d:\screen.bmp
EndIf
ScreenCapture>X,Y,W,H,d:\screen.bmp

LibFunc>imglib,FindImgPos,imgs,d:\googlebutton.bmp,d:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
//click on button
//remember that x,y returned is relative the image and since we didn't use the
//full screen we will need add top left offset to get screen coordinates
Let>x=imgs_5+x
Let>y=imgs_6+y
MouseMove>x,y
LClick
Endif

LibFree>imglib
________
Honda RA106 specifications
Last edited by adivarup on Wed Feb 02, 2011 12:36 pm, edited 1 time in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Mar 29, 2006 1:09 am

Revised:

This should work, I think you missed the If>imgs>0

If>imgs>0

Let>x=imgs_5+x
Let>y=imgs_6+y
MouseMove>x,y
LClick
Endif

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Mar 29, 2006 2:23 am

I think you should start with a fresh copy, because I now tested the example code (below) and it works fine.

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

//Focus Google
SetFocus>Google - Microsoft Internet Explorer
Wait>1
//Get bounds of window
GetActiveWindow>title,X,Y,W,H

//Capture the screen to a bitmap
IfFileExists>c:\screen.bmp
DeleteFile>c:\screen.bmp
EndIf
ScreenCapture>X,Y,W,H,c:\screen.bmp

LibFunc>imglib,FindImgPos,imgs,c:\googlebutton.bmp,c:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
//click on button
//remember that x,y returned is relative the image and since we didn't use the
//full screen we will need add top left offset to get screen coordinates
Let>x=imgs_5+x
Let>y=imgs_6+y
MouseMove>x,y
LClick
Endif

LibFree>imglib

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Wed Mar 29, 2006 2:28 am

Ok - UNCLE!

So i tested my script a min ago, and it worked.. I saw it find the opened IE, it clicked submit.

Then ran the script again and nothing.. It did nothing.

I am using your script, and nothing happens. I looked at the image file it created and there is only a partial image of the google page. Nothing really showing in that image because it is so thin.
________
clear trichomes
Last edited by adivarup on Wed Feb 02, 2011 12:37 pm, edited 1 time in total.

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 Mar 29, 2006 7:19 am

That script works for me every time. However, since no search query has been entered you won't notice much happening. Another thing to be careful of - when capturing the google button make sure it is not focused. When the button is focused it becomes highlighted so it will be a different image. Either capture the middle portion of the button, or make sure it is not focused if you capture the entire button.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Wed Mar 29, 2006 9:46 pm

I think i see the issue. I have been pounding my head on this since yesterday.

My screen size is 1920 / 1200.

The file DOES work in its original format ONLY if IE is opened up in normal view and the window is set in the top left most corner of my screen. But in my case, I had the scripting window opened on the left screen and the IE window opened on the right screen. With my resolution I can have two screens opened in full view.

So I tested again this morning, making sure the i copied the images correctly, (which is great advise) and it does seem to work.

I am sure that this should work with higher resolution screens and could look across the entier screen, otherwise the only way to make this work is if IE opens in the top left window.
________
AMC Gremlin history
Last edited by adivarup on Wed Feb 02, 2011 12:37 pm, edited 1 time in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Mar 29, 2006 10:59 pm

Try running it with the macro scheduler window not open, ie minimized to the system tray, right click on the system tray icon and select quick launch and click on the script. That's how it worked for me, I don't think the macroscheduler window likes to give up focus.

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Wed Mar 29, 2006 11:21 pm

I just tried what you suggested. The only way this will work is if the IE window is open and placed to the far left. If I have the window opened anywhere else on the desktop, it will not work.
________
Honda FC Sport specifications
Last edited by adivarup on Wed Feb 02, 2011 12:37 pm, edited 1 time in total.

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