Phaser Posted September 17, 2009 Share Posted September 17, 2009 (edited) Hi everyone I have an app that clicks a button using controlclick, I have a sleep time before it set to 1 second, the button reloads perfect 99% of the time BUT I just noticed it hang and subsequently it missed a piece of data, heres what I currently have Func thebutton() Sleep($sleep) ControlClick("Window name", "", "", "left", 1, $x, $y) Sleep($sleep) EndFunc I would like to use PixelGetColor in an if statement but am not sure what to do if it is not ready, I dont see putting a wait time as the best route because it is difficult to know how long it wont be ready. $sb = PixelGetColor( 125 , 927, $hWnd ) if $sb = 0x009564 Then ; push the button Else ; what to do here?? EndIf Any ideas as to the best approach? Edited September 17, 2009 by Phaser Link to comment Share on other sites More sharing options...
Zedna Posted September 17, 2009 Share Posted September 17, 2009 What's your app? And what's going on after your ControlClick? Crystal ball says nothing about all of this :-) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Phaser Posted September 17, 2009 Author Share Posted September 17, 2009 you must have a low quality crystal ball The button is sending a signal via the internet from a local exe windows application, when the web is quiet all is well but when the server is busy sometimes the button doesn't show up as quick as it should after clicking so I thought if the pixel color of the button isn't visible, don't click yet, wait, recheck and either click, if button is visible or wait again. The window still stays active during the hesitation period, so I am not sure what to do, any help or pointers would be gratefully appreciated. I must wait for the button or data gets missed as controlclick is still clicking but the button is MIA Link to comment Share on other sites More sharing options...
Zedna Posted September 17, 2009 Share Posted September 17, 2009 While ControlCommand('title','text','Button1','IsEnabled','') = 0 Sleep(100) WEnd Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Phaser Posted September 17, 2009 Author Share Posted September 17, 2009 The control has no ID its not an internet html type button, its actually a graphic thats why I think pixelgetcolor would be best. I have just been looking at the help file, something like ProcessWait should work "The process is polled approximately every 250 milliseconds." Could it be made to check the pixel color? thats all I need it to do, if the pixel isn't the color it should be, hang around and keep checking it until it is the correct colour then click, is that possible? or something similar Link to comment Share on other sites More sharing options...
JohnOne Posted September 18, 2009 Share Posted September 18, 2009 (edited) I was having a similar issue Done it like this Do $sb = PixelGetColor( 125 , 927, $hWnd ) Until $sb = 0x009564 if $sb = 0x009564 Then ; push the button Else ; what to do here?? EndIf Probably not the swankiest way to do it but works for me. I'm not certain but you may aslo be able to remove the if else that way too But it should work as is Edited September 18, 2009 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Phaser Posted September 18, 2009 Author Share Posted September 18, 2009 cheers JohnOne exactly what I needed, I did remove the if else as its not needed now, thanks again Do $sb = PixelGetColor( 125 , 927, $hWnd ) Until $sb = 0x009564 Link to comment Share on other sites More sharing options...
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