Bind a key to toggle loop on/off

Get help with using AutoHotkey and its commands and hotkeys
Batsmaru0410
Posts: 11
Joined: 19 Jan 2019, 12:25

Bind a key to toggle loop on/off

17 Oct 2020, 05:27

Hi, I have made a loop script to search for two images. When found, it will play bye.wav.

How do I bind it to a key to toggle the loop on and off. Thanks you.

Code: Select all


CoordMode, Pixel, Screen


Loop

{

	ImageSearch, FoundX, FoundY, 1, 641, 354, 1025, *100 Talk.png

	if ErrorLevel = 0
		
	{
		SoundPlay, bye.wav		
		Sleep 2000	
	}

	
	ImageSearch, FoundX, FoundY, 1, 641, 354, 1025, *100 Talk2.png

	if ErrorLevel = 0
		
	{
		SoundPlay, bye.wav		
		Sleep 2000	
	}



}

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

Re: Bind a key to toggle loop on/off

17 Oct 2020, 05:59

Hallo,
try:

Code: Select all

CoordMode, Pixel, Screen
F1:: ;On/Off with key F1
If TF1 := !TF1
	SetTimer TF1
Else
	SetTimer TF1, Off
Return
TF1:
While, !Picture := Pictures.RemoveAt(1)
	Pictures := ["Talk.png","Talk2.png"]
ImageSearch, FoundX, FoundY, 1, 641, 354, 1025, *100 %Picture%
if ErrorLevel = 0
{
	SoundPlay, bye.wav
	Sleep 2000
}
Return

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], Google [Bot], return, songdg, zvit and 49 guests