
Sistema padrãoCaixa de diálogo ImprimirouCaixa de diálogo Salvarestá engolindo chaves enviadasimediatamente após a abertura. Existe uma maneira de enviar chaves com sucesso o mais rápido possível?
Detalhes:
Vejamos alguns casos de uso simples da caixa de diálogo Imprimir, ou seja, se você pressionar Ctrl+ Pno Internet Explorer. Assim que abrir, só quero enviar Alt+ ppara pressionar oImprimirbotão o mais rápido possível. Mas o seguinte script não funciona:
#IfWinActive, ahk_class IEFrame
F2::
Send ^p
WinWait, Print,, 2
Send !p ; this has no effect if sent immediately
Return
#IfWinActive
Ele começa a funcionar quando eu insiro Sleep 500
antes Send !p
. Mas talvez 500 ms não sejam suficientes em alguns casos. Existe alguma maneira elegante de inserir teclas digitadas o mais rápido possível?
Responder1
#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
ou
; 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, ...
...