AutoHotKey – 시스템 대화 상자가 키 입력을 받아들일 수 있을 때까지 기다리는 우아한 방법이요?

AutoHotKey – 시스템 대화 상자가 키 입력을 받아들일 수 있을 때까지 기다리는 우아한 방법이요?

표준 시스템인쇄 대화 상자또는저장 대화상자삼키는 열쇠가 전송되었습니다개봉 직후. 가능한 한 빨리 키를 성공적으로 보내는 방법이 있습니까?

세부:

인쇄 대화 상자의 몇 가지 간단한 사용 사례를 살펴보겠습니다. 즉, Internet Explorer에서 Ctrl+를 누르는 경우입니다. P일단 열리면 Alt+를 p보내서인쇄최대한 빨리 버튼을 누르세요. 그러나 다음 스크립트는 작동하지 않습니다.

#IfWinActive, ahk_class IEFrame
F2::
    Send ^p
    WinWait, Print,, 2
    Send !p   ; this has no effect if sent immediately
Return
#IfWinActive

Sleep 500앞에 삽입하면 작동이 시작됩니다 Send !p. 그러나 어떤 경우에는 500ms만으로는 충분하지 않을 수도 있습니다. 최대한 빨리 키 입력을 삽입하는 우아한 방법이 있나요?

답변1

#IfWinActive, ahk_class IEFrame

F2:: 
    Send ^p
    WinWait, Print ahk_class #32770     ; Waits until the specified window exists
    IfWinNotActive, Print ahk_class #32770, ,WinActivate, Print ahk_class #32770
    WinWaitActive, Print ahk_class #32770   ; Waits until the specified window is active 
    Send !p
Return

#IfWinActive

또는

; WinWait, WinTitle, WinText, Seconds, ExcludeTitle, ExcludeText

WinWait, Print ahk_class #32770, WinText  ; Use Window Spy to find out a single text element of the target window 
IfWinNotActive, ...
...

관련 정보