AHK:关闭 window 每当它弹出

AHK: closing a window whenever it pops up

我编写了一个 AHK 脚本,旨在在我按 F9 时从 Adob​​e Acrobat 复制文本。然后它根据正则表达式更改它并在工具提示中显示复制的文本。此外,我添加了代码以自动关闭 Acrobat 在处理文本时有时会显示的烦人的 window,以及臭名昭著的 There was an error while copying to Clipboard. An internal error occurred. 当此 window 未显示时,脚本会一直显示工具提示,它被设计为在指定的时间后关闭。我一直在用头撞墙,但我不知道如何纠正这个问题。

;#NoTrayIcon
#Persistent
#SingleInstance
F9::
#If WinActive("ahk_exe Acrobat.exe")
{
Clipboard:=""
send,^c
ClipWait, 1
Clipboard := RegExReplace(Clipboard, "\r\n", " ")
SetTimer,CheckForMsgBox,100
CheckForMsgBox:
    IfWinExist, Adobe Acrobat
    {
        Send {Enter}
        SetTimer,CheckForMsgBox,Off
    }
;Return
If (StrLen(Clipboard) < 120)
ToolTip % Clipboard
Else
ToolTip Copied
SetTimer, ToolTipOff, -1000
return
}
#If

ToolTipOff:
ToolTip
return
;#NoTrayIcon
; #Persistent ; (1)
#SingleInstance
SetTimer,CheckForMsgBox,100 ; (2)
return

#If WinActive("ahk_exe Acrobat.exe") ; (3)

F9::    
clipboard:=""
send,^c
ClipWait, 1
Clipboard := RegExReplace(Clipboard, "\r\n", " ")
If (StrLen(Clipboard) < 120)
    ToolTip %Clipboard%
Else
    ToolTip Copied
SetTimer, ToolTipOff, -1000
return

#If  ; turn off context sensitivity

ToolTipOff:
ToolTip
return

CheckForMsgBox:
; ControlSend, Control, Keys, WinTitle, WinText, ExcludeTitle, ExcludeText
ControlSend, , {Enter}, Adobe Acrobat  ; Close this unwanted window whenever it appears
return

(1) 包含热键、热字串或任何对 OnMessage() 或 Gui 的使用的脚本自动 持久

(2) SetTimer 使子程序 (Label) 以指定的时间间隔自动重复启动。

https://autohotkey.com/docs/commands/SetTimer.htm

(3) 与#IfWin 指令一样,#If 是位置性的:它在物理上影响所有热键和热字串 在它下面脚本。

https://autohotkey.com/docs/commands/_If.htm