how to click the button until it's gone? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
styner
Posts: 5
Joined: 24 Mar 2018, 05:09

how to click the button until it's gone?

15 Sep 2018, 14:06

So I have button A and button B. Button B appears immediately after button A is clicked but the problem is when button B appears, sometimes there is network delay. Due to the network delay, button B is on the screen but it's briefly disabled and unclickable. How do I modify the code so that autohotkey clicks until the button is gone? I know I can simply add time delay before pressing button B but that would only increase whole script running time and network delay randomly appears 1 out of 10 situations. Btw, when button B is properly clicked, it disappears and the system moves onto the next page.

Code: Select all

ImageSearch, x,y,  %pos_x%, %pos_y%, %x_right%, %y_bottom%, *50 buttonA.bmp
if (ErrorLevel= 0)
{
	Send {Click %x% %y%}
	ImageSearch, x1,y1,  %pos_x%, %pos_y%, %x_right%, %y_bottom%, *50 buttonB.bmp
	{
		if (ErrorLevel = 0)
		{
			Send {Click %x1% %y1%} ;how do I make this click command repeated until button B is gone?
		}
	}
}


Many thx for this newbie question!
User avatar
Xtra
Posts: 1241
Joined: 02 Oct 2015, 12:15

Re: how to click the button until it's gone?  Topic is solved

15 Sep 2018, 15:21

Code: Select all

ImageSearch, x,y,  %pos_x%, %pos_y%, %x_right%, %y_bottom%, *50 buttonA.bmp
if (ErrorLevel= 0)
{
	Send {Click %x% %y%}
    Sleep 500
    Loop
    {
        ImageSearch, x1,y1,  %pos_x%, %pos_y%, %x_right%, %y_bottom%, *50 buttonB.bmp
        {
            if (ErrorLevel = 0)
            {
                found := true
                Send {Click %x1% %y1%} ;how do I make this click command repeated until button B is gone?
            }
        }
        Sleep 500        
    }until (found && ErrorLevel)
}
styner
Posts: 5
Joined: 24 Mar 2018, 05:09

Re: how to click the button until it's gone?

16 Sep 2018, 19:48

Alright thx! I will try that and see if it works well :)

Return to “Ask For Help”

Who is online

Users browsing this forum: empleat, L40P and 57 guests