WaitPixelColor problem

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

buksi
Newbie
Posts: 9
Joined: Thu Sep 15, 2005 11:28 am

WaitPixelColor problem

Post by buksi » Thu Sep 15, 2005 11:42 am

Hi. I'm newbie and I don't speak english very well, but I want to solve my problem with someone's help. I want to use a macro to play an online game. Here is the link:http://www.gameaccount.com/toModule.do; ... ix=%2Fgolf
It is a slider in the game and it is yellow and moves up and down on the x axis. If I click on the button the slider stop. I want to stop the slider on an exact point so the script gonna wait to changing the color on the specified coordinate and than click. If someone see the game than realize to my problem.
Here is my code:

MouseMove>312,664
LClick
WaitPixelColor>65535,529,664,0
MouseMove>312,664
LClick
WaitPixelColor>65535,349,664,0
MouseMove>312,664
LClick

Sometimes it works correctly sometimes not:?
Why?
(My monitor display is 1024x768@85Hz)
Thanks and sorry for my bad english.
Last edited by buksi on Thu Sep 15, 2005 12:07 pm, edited 1 time in total.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Sep 15, 2005 12:04 pm

There aren't many games players here I'm afraid. People here are generally writing scripts to automate critical business functions and they therefore take priority. Anyway, why would you want a macro to play a game!? Seems pointless to me.
MJT Net Support
[email protected]

buksi
Newbie
Posts: 9
Joined: Thu Sep 15, 2005 11:28 am

Post by buksi » Thu Sep 15, 2005 12:14 pm

support wrote:There aren't many games players here I'm afraid. People here are generally writing scripts to automate critical business functions and they therefore take priority. Anyway, why would you want a macro to play a game!? Seems pointless to me.
OK. I understood this, but I can't realize why don't operate well my code. I think the WaitPixelColor function isn't work correctly. Please take a look for the link and you will seeing what I'm talking about. Please.

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 » Thu Sep 15, 2005 4:14 pm

Don't understand why you move the mouse three times to the same location.

What is not working, left click? How do you know?
What is supposed to happen...a pixel changes color in another location?

Some thoughtx:
1. You are using a timeout value of 0 which can make the system appear to "hang". Try using a real value and branching based on result.

2. May want to use WaitRectChanged> vs. Pixel. Pixel may be too small for checking.

3. Look at log results to see exactly what is happening in real time.
Last edited by Bob Hansen on Fri Sep 16, 2005 4:24 am, edited 1 time in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Sep 15, 2005 4:18 pm

For a start there is no SetFocus command. There is nothing in this script to ensure the correct window has the focus. If you run this script manually Macro Scheduler will have the focus. You need to add something to make sure the left click lands on the right window.
MJT Net Support
[email protected]

buksi
Newbie
Posts: 9
Joined: Thu Sep 15, 2005 11:28 am

Post by buksi » Thu Sep 15, 2005 4:50 pm

Did you see the game under the link? When u see the game all gonna clear. I will probe your advices soon and I will tell u the news. Thanks for the helps.

buksi
Newbie
Posts: 9
Joined: Thu Sep 15, 2005 11:28 am

Post by buksi » Fri Sep 16, 2005 4:17 am

Here is my new code:

SetFocus>GameAccount*
MouseMove>312,664
LClick
WaitPixelColor>65535,529,664,0
MouseMove>312,664
LClick
WaitRectChanged>348,659,348,671,1.1
//WaitPixelColor>65535,349,664,0
MouseMove>312,664
LClick


It's better than old one, but it isn't work on 100%. Sometimes miss the waitrectchanged or waitpixelcolor function. The clicks are ok, but I think the second color recognize isn't perfect (for first is ok). What do u think? Please take a a look to the game, and u will see what happen. Jah, and have u gote any idea instead of Wait>. It isn't exact.
Thx

Luciano
Junior Coder
Posts: 31
Joined: Fri Feb 11, 2005 1:10 pm
Location: Ghent, BELGIUM

Post by Luciano » Fri Sep 16, 2005 8:52 am

Take a look to the BLOCKINPUT statement. Touching the mouse while the script is running can move the mouse cursor between statements. Blocking the input is the only way to be sure that the LCLIK executes on the correct coordinate.
Possible this does not solve your problem, but’s a good practice to block the input while using the MOUSEMOVE statement.

Greetings

Luciano

buksi
Newbie
Posts: 9
Joined: Thu Sep 15, 2005 11:28 am

Post by buksi » Fri Sep 16, 2005 9:35 am

Thank u for the advice, but I think not the mouse click is the problem because I probe this code with Wait> instead of Waitpixelcolor> and it does always work. The click is not to important I think.
Please check the game what I shown.

buckw1
Junior Coder
Posts: 20
Joined: Sun Sep 18, 2005 5:08 am

Post by buckw1 » Sun Sep 18, 2005 5:10 am

Hi,
I tried the game and your script, macroscheduler is not fast enough to detect the color bar.....nice golf game..

buksi
Newbie
Posts: 9
Joined: Thu Sep 15, 2005 11:28 am

Post by buksi » Sun Sep 18, 2005 9:05 am

Yeah, I think so. Have u got any idea for this problem?
How can I detect the color change?
Thx.

JRS
Pro Scripter
Posts: 71
Joined: Thu Nov 04, 2004 5:19 am

Post by JRS » Mon Sep 19, 2005 8:07 am

All,

I've encountered a phenomena with respect to pixel colors
that I think is relevent to this thread - instead of starting another.
In my application I interact with the http://www.betfair.com webpage
using Macro Scheduler.

I do a Relative mouse move (MouseMoveRel) to the scroll bar -
put in a second or 2 wait and then do a "Get Pixel Color":

GetPixelColor>652,355,PC
Message>Pixel Color is : %PC%

(not my actual coodinates - the preceding is taken directly
from the Macro Scheduler help example) Instead of
using Message> I use MessageModal>

The scroll bar color differential is dark gray and light gray
similar in nature to the scroll bar in this forum window. I get
the same Pixel Color result if I'm in the light portion of the
vertical scroll bar area or in the dark section.

I don't have the exact Pixel color result but it really doesn't
matter, it just seems with the large number that comes back
there should "room" for a differentiation for all colors,
"encountered". In other words there's plenty of "room" for
a light gray and dark gray distinction or differentiation.

I know for sure that I'm solidly in the light gray area or the
dark gray area of the scroll bar when I make my Get Pixel
Color "call".

I was wondering if there is a listing of all the color number
definitions recognized or accepted by Macro Scheduler.

I hope I make sense in my question here. I've tried my best
to explain it.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Sep 21, 2005 2:54 pm

One thing you should do is move the window to 0,0 for example, that way the spot you're having MS read the color from is always in the same position.


MoveWindow>GameAccount*,0,0
MouseMove>312,664
LClick
WaitPixelColor>65535,529,664,0
MouseMove>312,664
LClick
WaitPixelColor>65535,349,664,0
MouseMove>312,664
LClick

You may have to change your cords for WaitPixelColor and MouseMove but once you have the correct cords you shouldn't have to mess with the script anymore.
Good Luck

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Sep 21, 2005 3:25 pm

I just took a look at the game and here is what I came up with for Windows XP. I had problems with WaitPixelColor since the power bar is so small. This script has 2 loops, each loop searches an area of 6 pixels and looks for the yellow and black color in the power bar.
I hope this helps.


MoveWindow>GameAccount*,0,0
MouseMove>74,351
LClick
label>loop1
GetPixelColor>265,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>loop2
endif
GetPixelColor>266,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>loop2
endif
GetPixelColor>267,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>loop2
endif
GetPixelColor>268,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>loop2
endif
GetPixelColor>267,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>loop2
endif
GetPixelColor>270,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>loop2
endif
goto>loop1

label>loop2
GetPixelColor>110,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>stop
endif
GetPixelColor>111,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>stop
endif
GetPixelColor>112,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>stop
endif
GetPixelColor>113,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>stop
endif
GetPixelColor>114,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>stop
endif
GetPixelColor>115,350,c
if>{(%c%=65535)or(%c%=0)}
MouseMove>74,351
LClick
goto>stop
endif
goto>loop2
label>stop

buksi
Newbie
Posts: 9
Joined: Thu Sep 15, 2005 11:28 am

Post by buksi » Wed Sep 21, 2005 4:11 pm

Thanks, but I think it isn't perfect, cause I have to stop the power bar at the same position .

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