Technical support and scripting issues
Moderators: JRL, Dorian (MJT support)
-
Dj Telo
- Junior Coder
- Posts: 24
- Joined: Sun Mar 21, 2010 7:27 pm
Post
by Dj Telo » Mon Mar 22, 2010 11:37 am
Hello everyone! I am a beginner and i need some help to create a loop wich allows me to scroll down a web page (with Press Down*numberoftimes) until a specific image is found, then click on it.
What I got now is very basic, it only works when the image is shown in the default view of the web page.
Code: Select all
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,E:\screen.bmp
FindImagePos>E:\image.bmp,E:\screen.bmp,20,1,XPos,YPos,imgs
If>imgs>0
MouseMove>XPos_0,YPos_0
LClick
Endif
I think I should use the comand Repeat and Until, but I don't know how to use them.
Thank you for your help!

-
Dj Telo
- Junior Coder
- Posts: 24
- Joined: Sun Mar 21, 2010 7:27 pm
Post
by Dj Telo » Tue Mar 23, 2010 4:44 pm
I've tried the following:
Code: Select all
Let>x=1
Repeat>x
Press Down*5
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,E:\screen.bmp
FindImagePos>E:\image.bmp,E:\screen.bmp,10,1,XPos,YPos,x
Wait 2
Until>x=0
If>x>0
MouseMove>XPos_0,YPos_0
Endif
It doesn't work. It seems to be that it only performs the loop once (you only see one scroll down movement) but it isn't because it finds the image already. I know the image is below the current view in which it stops.
Any suggestions? Thank you.
-
JRL
- Automation Wizard
- Posts: 3532
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Tue Mar 23, 2010 5:38 pm
You're close.
Try this and let us know. Be sure to set the "browser" variable to text that will find the browser you're using. Also, as a general rule, even though you will find examples that do everywhere, try not to use single characters as variable names
Code: Select all
Let>Browser=Mozilla Firefox
Let>kk=0
Repeat>kk
Add>kk,1
SetFocus>%browser%*
FindImagePos>C:\image.bmp,SCREEN,2,1,XPos,YPos,numfound
If>numfound<>0
Let>kk=1000
Else
Press down*5
EndIf
Until>kk=1000
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Tue Mar 23, 2010 8:19 pm
Personally I'd press down only once in each iteration. Pressing it more than once means you could scroll past the image and then never find it.
-
JRL
- Automation Wizard
- Posts: 3532
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Tue Mar 23, 2010 8:38 pm
Is the up or down arrow increment adjustable? On my computer in Firefox I only get a line's worth of movement with each press of an up/dn arrow key. No chance of scrolling too far. That was why I set the upper loop limit at 1000. On a big page that might not be anywhere near enough.
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Tue Mar 23, 2010 8:49 pm
Sorry. I was thinking PAGE down. I would do ONE PAGE down at a time. That should ensure you always scroll enough but not too much. Pressing down 5 times seems rather dependent on window size to me. Page down should always be just right by definition.
-
Dj Telo
- Junior Coder
- Posts: 24
- Joined: Sun Mar 21, 2010 7:27 pm
Post
by Dj Telo » Tue Mar 23, 2010 9:23 pm
Thank you both! It is already working. In this case, pressing down 5 times is already enough for my purpose, but I will keep that in mind for the future.
