Click a toggle on a resizable window

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
GregS
Newbie
Posts: 7
Joined: Tue Jun 06, 2006 10:47 pm

Click a toggle on a resizable window

Post by GregS » Thu Jun 08, 2006 1:11 am

Hello,

I have a window that is split screen and the two halves can be resizes. I have a text entry field that is a number and increased or decreased by clicking in either the up or down arrow buttons next to the text box. There is a label “textâ€Â

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

Post by Marcus Tettmar » Thu Jun 08, 2006 5:52 am

Sounds like a case for the Image Recognition Library. Using this you can have the script find the location of the up arrow button and click it. See examples that come with the image recognition library:
http://www.mjtnet.com/imagerecognition.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

GregS
Newbie
Posts: 7
Joined: Tue Jun 06, 2006 10:47 pm

Problems with Image Lib Examples

Post by GregS » Thu Jun 08, 2006 9:38 pm

Hello,

Download image library examples, however; I cannot get "Google Button" & "Password" examples to work. I have the bitmaps in the correct place. I keep getting "invalid numberic value for mosemove command" for "MouseMove>imgs_5,imgs_6" Tried to display values of imgs_5 & imgs_6 in message command and displayed no value.

Any ideas?

Cheers.

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

Post by Marcus Tettmar » Thu Jun 08, 2006 9:41 pm

Could you post your script - only my crystal ball aint working today and I need a bit more to go on ... ;-)

Seriously, post your script and we'll be better able to tell you what might be wrong.

Also please confirm which version of Macro Scheduler you are running. Check under Help/About.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

GregS
Newbie
Posts: 7
Joined: Tue Jun 06, 2006 10:47 pm

Sorry!

Post by GregS » Thu Jun 08, 2006 9:54 pm

Here you go,

I have version 8.0.3e



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

MessageModal>%X% %Y% %W% %H%

//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

MessageModal>%imgs_5% %imgs_6%

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

LibFree>imglib

***** and ***************

VBSTART
Sub OpenPage(URL,Wait)
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
IE.navigate URL
do while IE.Busy and Wait
loop
End Sub
VBEND

//Go to the flash password example at Webwasp.co.uk
VBRun>OpenPage,http://www.webwasp.co.uk/flash-sample-m ... ndex.php,1
WaitReady>0
SetFocus>Flash Tutorial: - webwasp.co.uk*

//Maximise IE
GetActiveWindow>title,X,Y
WindowAction>1,title

//Normally we can't automate clicking on flash buttons because they are only images.
//Now we can use FindImgPos to locate the flash button ...

//I have used Capture.exe to extract the password edit box and the edit button to bitmaps:
Let>editbox=d:\passwordedit.bmp
Let>enterbutton=d:\enterbutton.bmp

//Load the library
Let>imglibDLL=%SCRIPT_DIR%\imglib.dll
LibLoad>imglibDll,imglib

//get screen res and capture full screen
LibFunc>imglib,GetScreenRes,screen,ref:0,ref:0
IfFileExists>d:\screen.bmp
DeleteFile>d:\screen.bmp
Endif
Wait>1
ScreenCapture>0,0,screen_1,screen_2,d:\screen.bmp

//Find the password box on the screen
LibFunc>imglib,FindImgPos,imgs,editbox,d:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
//Click in box
MouseMove>imgs_5,imgs_6
LClick
//Enter a password
Send>private
Endif

//Find the password box on the screen
LibFunc>imglib,FindImgPos,imgs,enterbutton,d:\screen.bmp,20,1,ref:0,ref:0
If>imgs>0
//Click on button
MouseMove>imgs_5,imgs_6
LClick
Endif

//Free library
LibFree>imglib

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

Post by Me_again » Fri Jun 09, 2006 12:25 am

I'll look at it more later but the first thing I see is:

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

Screen Capture doesn't use Width and Height it needs coordinates for the four corners of the capture area, so you have to calculate X and Y for the lower right corner and then:

ScreenCapture>X1,Y1,X2,Y2,Filename

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

Post by Marcus Tettmar » Fri Jun 09, 2006 6:54 am

Do these image files exist:

d:\passwordedit.bmp
d:\enterbutton.bmp

Did you make sure imglib.dll is in the same directory as your script?

When you step through the script line by line with the debugger what is the value for imglib?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

GregS
Newbie
Posts: 7
Joined: Tue Jun 06, 2006 10:47 pm

Put DLL in folder of script, Works!

Post by GregS » Fri Jun 09, 2006 3:55 pm

Hello,

Put recommended DLL in same folder as script and it worked. Thanks.

Now, suggestions how to speed up the process. Reduce the capture screen area?

Thanks & cheers,

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