每当我关闭特殊程序时,退出脚本自动热键

时间:2020-06-08 14:31:22

标签: 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 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时也关闭脚本。.我在AutoHotKey网站上尝试了很多方法,例如: 进程,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

但它们都不起作用

请帮助我 谢谢

2 个答案:

答案 0 :(得分:1)

尝试使用WinWaitClose,然后使用ExitApp

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

// [...]

答案 1 :(得分:-1)

IfWinNotExist, ahk_exe Sonos.exe