FindText not working with SetTimer Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
haomingchen1998
Posts: 168
Joined: 20 Feb 2023, 16:37

FindText not working with SetTimer

Post by haomingchen1998 » 07 Jun 2023, 15:20

I wrote a simple script to look for the login button from wechat every 1 second, and controlclick on it when it finds it. But it doesn't click on the button when I use SetTimer, it only works when I assign a hotkey to trigger it. What have I done wrong? Thanks!

Code: Select all

SetTimer, WeChatlogin, 1000

WeChatlogin:
   if (ok:=FindText(X,Y,,,,,,,"|<>*180$101.zzzzzzzzzzzzz7zzzkDzzzzzbnnzw6DzzzDDzzzzz77bznYTzwQzDzzzzzCDDzDszzstyN3kN3yQAsAzk7VUHyFnAFbwmNa9zX6tX7wbYwbbwYmSHz7Dn6DtD81DDtAA0byCQ6CTaSHySTmsNzDwQXAQzAwXwwzVklzDstCMwwslbNtzXVniCFmMtw3k7Unnz7bkT1Xa1kzzbzzzzzzzzzzzzzzzzDzzzzzzzzzzzzzzzyTzzzzzzzzzzzzzzzwzzzzzzzzzzzzzzs")) {
      FindText().ScreenToWindow(outX, outY, X, Y, WinExist("ahk_class WeChatLoginWndForPC")) 
      ControlClick, X%outX% Y%outY%, ahk_class WeChatLoginWndForPC 
   }
return

User avatar
mikeyww
Posts: 26851
Joined: 09 Sep 2014, 18:38

Re: FindText not working with SetTimer  Topic is solved

Post by mikeyww » 07 Jun 2023, 18:44

The script exits when the Return command is reached.

Explained: #Persistent

haomingchen1998
Posts: 168
Joined: 20 Feb 2023, 16:37

Re: FindText not working with SetTimer

Post by haomingchen1998 » 07 Jun 2023, 19:11

mikeyww wrote:
07 Jun 2023, 18:44
The script exits when the Return command is reached.

Explained: #Persistent
Can't believe it's such a newbie mistake, thank you!

Post Reply

Return to “Ask for Help (v1)”