我有这个小小的Autohotkey脚本可以很好地切换蓝牙:
SendMode Input
Run, ms-settings:bluetooth
WinWaitActive, Settings
Sleep 300
Send,{Tab}{Space}
WinClose, A
但我对那里的Sleep 300
感到有些困扰。似乎尽管WinWaitActive
应用程序并不是真正活跃的,但我需要等待它,我找不到比指定时间更好的东西。等待什么会更好?
答案 0 :(得分:0)
SendMode Input
Run, ms-settings:bluetooth
WinWait, Settings ; or:
/*
WinWait, Settings,, 2 ; wait 2 seconds maximally until the specified window exists
if ErrorLevel ; if the command timed out
{
MsgBox, WinWait timed out.
return
}
*/
IfWinNotActive, Settings, ,WinActivate, Settings
WinWaitActive, Settings ; or:
/*
WinWaitActive, Settings,, 2 ; wait 2 seconds maximally until the specified window is active
if ErrorLevel
{
MsgBox, WinWaitActive timed out.
return
}
*/
; Sleep 300 ; needed in some programs that may not react immediately after activated
Send,{Tab}{Space}
WinClose, A