Hello,
I would like a shove in the right direction. I'm attempting to write a script that will wait for a window to open, get the position of the window, and then if a pixel exists wherever the location of the window, click it. Here is what I'm thinking so far, however, I cannot find out how to properly use the ADD function.
WWO>Window*
GWP>Window,AX,AY
Add>X,AX
Add>Y,AY
GPC>X,Y,PC
IF>%PC%=123456,do_this
///
Label>do_this
Wai>0.3
Lcl
How exactly do I get this working for a specific color in the window? How do I know what to set the X,Y in the ADD> commands to?
Thanks.
GetWindowPos then find Pixel
Moderators: JRL, Dorian (MJT support)
- aboredprogrammer
- Junior Coder
- Posts: 40
- Joined: Wed Jan 27, 2010 6:31 am
GetWindowPos then find Pixel
aboredprogrammer
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
If you mean you want to monitor all pixels within the bounds of a window, then you probably want something like this:
You might also benefit from the FindColor plugin - this will more quickly find the pixel position of a colour in a given rectangle:
http://www.mjtnet.com/plugins.htm
Code: Select all
//What window are we interested in
Let>title=Notepad*
//get coordinates of window
GetWindowPos>title,X1,Y1
//Get width and height of window
GetWindowSize>title,W,H
//calculate bottom right coordinates of window
Let>right=X1+W
Let>bottom=Y1+H
//now look at all pixels within the bounds of the window
Let>x=X1
Repeat>x
Let>y=Y1
Repeat>y
GetPixelColor>x,y,pColor
If>pColor=123456
GoSub>DoSomething
//and do you want to pop out of loop here?
//Goto>end_loop
Endif
Let>y=y+1
Until>=bottom
Let>x=x+1
Until>x=right
Label>end_loop
SRT>DoSomething
//whatever .....
END>DoSomething
http://www.mjtnet.com/plugins.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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- aboredprogrammer
- Junior Coder
- Posts: 40
- Joined: Wed Jan 27, 2010 6:31 am
Thanks for the reply mtettmar.
I downloaded the Findcolor.dll, and that seems to work perfect. However, since I changed the search area to my whole screen, it takes about 2 seconds to find the pixel. This is much expected since it has a much larger space to search, but is there any way to speed it up at all?
I tried the script you posted, and I'm not too sure it's compatible with v10.022, since it comes up with many errors, and the GetWindowSize> is not recognized.
Thank you very much for the response!
I downloaded the Findcolor.dll, and that seems to work perfect. However, since I changed the search area to my whole screen, it takes about 2 seconds to find the pixel. This is much expected since it has a much larger space to search, but is there any way to speed it up at all?
I tried the script you posted, and I'm not too sure it's compatible with v10.022, since it comes up with many errors, and the GetWindowSize> is not recognized.
Thank you very much for the response!
aboredprogrammer