Autohotkey 每当我关闭spesific程序| |自动热键时退出脚本

Autohotkey 每当我关闭spesific程序| |自动热键时退出脚本,autohotkey,Autohotkey,首先,这里是代码 #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliabili

首先,这里是代码

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance Force
IfWinNotExist, ahk_exe VisualBoyAdvance.exe
{
    Run, VisualBoyAdvance.exe, D:\Games\GAMEBOY ADVANCE (.gba)\GBA\emu
    WinWait, ahk_exe VisualBoyAdvance.exe
    WinActivate, ahk_exe VisualBoyAdvance.exe
    return
}
WinActivate, ahk_exe VisualBoyAdvance.exe
sleep, 1000
MouseClick,,22,40
sleep,100
MouseClick,,116,257
sleep,100
MouseClick,,342,312
sleep,100
MouseClick,,179,16
return
Joy4::
MouseClick,,77,43
sleep, 100
MouseClick,,111,105
sleep, 100
MouseClick,,263,217
sleep, 100
MouseMove, 1380, 251
return
Joy1::
Send, {Shift Down}
Sleep, 100
Send, {F1}
Sleep, 100
Send, {Shift Up}
Return
Joy12::Send, {F1}
return
;LCtrl::
;ExitApp
它基本上是从VBA最新列表的顶部打开的VisualBoyAdvance,我想每当我关闭VBA时,脚本也会关闭。。我在自动热键网站上尝试了很多方法,比如: 进程,WaitClose,exwfile.exe 出口 返回 或

但它们都不起作用

请帮帮我 谢谢

尝试使用,然后:

尝试使用以下命令:

RunWait, calc
ExitApp
Run, C:\Program Files (x86)\Sonos\Sonos.exe
WinWait, ahk_exe Sonos.exe
SetTimer,Sonos,100

Sonos:
IfWinNotExist, Sonos
     ExitApp
Return
IfWinNotExist, ahk_exe Sonos.exe
// [...]
sleep,100
MouseClick,,179,16
WinWaitClose, ahk_exe VisualBoyAdvance.exe
ExitApp
Return

// [...]