开发者

autohotkey: how to avoid "focus lost" problem

I have such autohotkey script:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior spe开发者_Go百科ed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Run file.exe              # takes ~30 seconds to start
WinWait User identification
Sleep 1000
Send administrator{tab}
Sleep 1000
Send password
Click 38, 196

I'm using this script at start-up to auto-logon one utility.

The problem is - if when this script is working (for about 2 seconds + application start-up time (about 30 seconds) 32 seconds in total) some other program pop-up a window about something (like new update available or antivirus claim or anything) the script doesn't work because the focus of the window "User identification" is lost.

How to workaround this problem? Should I use another tool (which one) or it's possible to solve this problem using autohotkey?

Thanks


I've used AutoScriptWriter program that generates code for me perfectly:

Run file.exe
WinWait, User identification,
IfWinNotActive, User identification, , WinActivate, User identification, 
WinWaitActive, User identification, 
Send, administrator{TAB}password{ENTER}

However ControlSend likely better choice

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜