hero88 Posted April 29, 2007 Posted April 29, 2007 Hi I have written a program to automate something and I would like for the script to wait until a specific buttons is clickable, I have the button colour and the coords, so I have created the following function, which I would think waits until a pixel is a specific colour, but it doesn't seem to work. If I just run the script, it doesn't click on the button which it should do directly after the function call, if on the other hand I insert this "MsgBox(0,"The decimal color is", $colour)" and only click ok on it when the button has turned clickable then it works ok. So if anyone can see if this should work or not, I would appreciate it. Func _WaitForPixelChange($colourvalue,$xcoord,$ycoord) Do $colour = PixelGetColor ( $xcoord, $ycoord) until $colour = $colourvalue EndFunc
herewasplato Posted April 29, 2007 Posted April 29, 2007 Welcome to the forum.When you call the function, is $colourvalue a decimal representation of the color of interest? Also, you might want a small sleep in your Do/Until loop to prevent 100% CPU usage. [size="1"][font="Arial"].[u].[/u][/font][/size]
hero88 Posted April 29, 2007 Author Posted April 29, 2007 Welcome to the forum.When you call the function, is $colourvalue a decimal representation of the color of interest? Also, you might want a small sleep in your Do/Until loop to prevent 100% CPU usage.Thank you.Yes it is a decimal value, good idea I will do that.
herewasplato Posted April 29, 2007 Posted April 29, 2007 (edited) This worked fine for me._WaitForPixelChange(255, 1145, 886) MsgBox(0, "", "") Func _WaitForPixelChange($colourvalue, $xcoord, $ycoord) Do Sleep(99) $colour = PixelGetColor($xcoord, $ycoord) Until $colour = $colourvalue EndFunc ;==>_WaitForPixelChangeAre you sure that you have the correct x, y locations? They can be with respect to the screen, window, client... Edit: See the AutoIt "Active Window Info" tool: Options > Coord Mode > ... Edited April 29, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
herewasplato Posted April 29, 2007 Posted April 29, 2007 This also works - but I changed the coords to the active window:Opt("PixelCoordMode", 0) _WaitForPixelChange(255, 1145, 12) MsgBox(0, "", "") Func _WaitForPixelChange($colourvalue, $xcoord, $ycoord) Do Sleep(99) $colour = PixelGetColor($xcoord, $ycoord) Until $colour = $colourvalue EndFunc ;==>_WaitForPixelChange [size="1"][font="Arial"].[u].[/u][/font][/size]
hero88 Posted April 29, 2007 Author Posted April 29, 2007 (edited) Doublepost Edited April 29, 2007 by hero88
hero88 Posted April 29, 2007 Author Posted April 29, 2007 It works for me when I insert the Sleep(99) statement. So thanks a lot, I will remember that, it was not something I would i found out by myself
herewasplato Posted April 29, 2007 Posted April 29, 2007 Glad that it is working for you. You can take the Sleep down to about 10 milliseconds if need be... 99 is just what I used because I was already on the "(" key. Enjoy AutoIt. [size="1"][font="Arial"].[u].[/u][/font][/size]
Zedna Posted April 29, 2007 Posted April 29, 2007 (edited) I have written a program to automate something and I would like for the script to wait until a specific buttons is clickable You can do it more effective/reliable way : ; wait until Button1 is enabled While ControlCommand("Your window title", "Your window text", "Button1","IsEnabled","") = 0 Sleep(50) WEnd Edited April 29, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now