How to cycle through keywords based on time elapsed?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
newcod3r
Posts: 505
Joined: 30 Sep 2021, 02:16

How to cycle through keywords based on time elapsed?

Post by newcod3r » 30 Sep 2022, 19:46

Sample script below that finds the unsubscribe button in emails:

If I press ^q for the first time, it should always search for unsubscribe.
If within the first 3 seconds I press ^q again and again, it should use other search terms (E.g. Manage Preferences, Click Here)
If upon URL change OR more than 5 seconds elapsed, it should default to searching for unsubscribe when I press ^q.

Not sure how to go about doing this. Suggestions welcome!

Code: Select all

^q:: ; Find Unsubscribe button in Gmail
Sendinput {end}^f
Sleep 200
SendInput Unsubscribe
Sendinput {esc}
Sleep 100
SendInput ^{enter}
return

Rohwedder
Posts: 7553
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to cycle through keywords based on time elapsed?

Post by Rohwedder » 01 Oct 2022, 01:24

Hallo,
without If upon URL change OR more than 5 seconds elapsed, try:

Code: Select all

^q::
Qcount++
IF Qcount = 1
	SetTimer, Qactions, -3000
Return
Qactions:
Switch Qcount
{
Case 1: ; search for unsubscribe
	Sendinput {end}^f
	Sleep 200
	SendInput Unsubscribe
	Sendinput {esc}
	Sleep 100
	SendInput ^{enter}
Case 2:
	MsgBox, search Manage Preferences
Case 3:
	MsgBox, Click Here
}
Qcount := 0
Return

Post Reply

Return to “Ask for Help (v1)”