Stop script after one of 2 programms is closed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Selbia

Stop script after one of 2 programms is closed

26 May 2018, 13:41

Code: Select all

SendMode Input
SetWorkingDir %A_ScriptDir%
$*lShift::
Loop
{
if not GetKeyState("lShift","P")
break
{
Sleep 020
Send {Space down}
Sleep 020
Send {Space up}
sleep 020
Send {d down}
Sleep 020
Send {Space down}
Sleep 020
Send {2 down}
Sleep 020
Send {2 up}
Sleep 020
Send {d up}
Sleep 020
Send {Space up}
Sleep 020
}
}
return
#NoTrayIcon
#NoEnv
#persistent
#singleinstance force
please place your code in [code][/code] tags!





i want to. if a game client "Game Clien" and "Untitled - Notepad" are opend the script works but if one of them are closed it should not to send any command anymore untill its opened again.
Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Stop script after one of 2 programms is closed

27 May 2018, 01:40

Hallo,
try:

Code: Select all

SetTitleMatchMode, 2
SendMode Input
SetWorkingDir %A_ScriptDir%
$*lShift::
Loop
{
	if not GetKeyState("lShift","P")
		break
	{
		Sleep 020
		Send {Space down}
		Sleep 020
		Send {Space up}
		Gosub, 2_Progs
		sleep 020
		Send {d down}
		Sleep 020
		Send {Space down}
		Sleep 020
		Send {2 down}
		Sleep 020
		Send {2 up}
		Sleep 020
		Send {d up}
		Sleep 020
		Send {Space up}
		Gosub, 2_Progs
		Sleep 020
	}
}
return
2_Progs:
	While !WinExist("Game Clien") Or !WinExist("Untitled - Notepad")
		Sleep, 100
Return
#NoTrayIcon
#NoEnv
#persistent
#singleinstance force

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, ht55cd3, mamo691 and 368 guests