【问题标题】:Exit the script whenever i close spesific program || AutoHotKey每当我关闭特定程序时退出脚本||自动热键
【发布时间】:2020-06-09 18:37:08
【问题描述】:

首先,这是代码

#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

但它们都不起作用

请帮帮我 谢谢

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    尝试使用WinWaitClose,后跟ExitApp

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

    【讨论】:

      【解决方案2】:
      IfWinNotExist, ahk_exe Sonos.exe
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-06-28
        • 1970-01-01
        • 2013-03-20
        • 1970-01-01
        • 1970-01-01
        • 2019-06-12
        • 1970-01-01
        相关资源
        最近更新 更多