Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Autohotkey 自动热键:如何避免;“焦点丢失”;问题_Autohotkey - Fatal编程技术网

Autohotkey 自动热键:如何避免;“焦点丢失”;问题

Autohotkey 自动热键:如何避免;“焦点丢失”;问题,autohotkey,Autohotkey,我有这样的自动热键脚本: #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent startin

我有这样的自动热键脚本:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed 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
我在启动时使用此脚本自动登录一个实用程序

问题是-如果此脚本工作时(大约2秒+应用程序启动时间(大约30秒)总共32秒),其他一些程序会弹出一个关于某个内容的窗口(如可用的新更新或防病毒声明或任何内容),则脚本无法工作,因为窗口“用户标识”的焦点丢失

如何解决这个问题?我应该使用其他工具(哪一个)还是可以使用自动热键解决此问题


谢谢

我使用了AutoScriptWriter程序,它可以完美地为我生成代码:

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

不过
ControlSend
可能是更好的选择

很高兴您能使用它。作为一个提示,也可以看看ControlSend和ControlClick命令。如果在当前脚本输入数据时有内容窃取了焦点,则会导致问题。将击键/单击直接发送到控件更可靠,并且不需要窗口具有焦点。