Jump to content

Best logic to check if app is ready


Phaser
 Share

Recommended Posts

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 by Phaser
Link to comment
Share on other sites

you must have a low quality crystal ball :D

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

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

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 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...