绕过 Windows 保护以允许自动热键发送

绕过 Windows 保护以允许自动热键发送

例如如果我这样做:

run Notepad.exe
sleep 500
send, test
return

当我远程登录时它会运行,但如果我安排任务来运行这个 .ahk,它会运行它但会停止发送命令。

我知道一种解决方案,不是正常注销,而是运行另一个 .bat 命令:

C:\Windows\System32\tscon.exe 0 /dest:console
C:\Windows\System32\tscon.exe 1 /dest:console
C:\Windows\System32\tscon.exe 2 /dest:console
C:\Windows\System32\tscon.exe 2 /dest:console
C:\Windows\System32\tscon.exe 3 /dest:console
C:\Windows\System32\tscon.exe 4 /dest:console
C:\Windows\System32\tscon.exe 5 /dest:console

但是我的电脑设置为每 3 天重启一次,然后它就无法再工作了。

编辑:它确实启动了记事本,因为当我登录时记事本是可见的,但它无法触发击键。

任务计划程序设置

[一般的]

选中 - 无论用户是否登录都运行 选中 - 以最高权限运行

[设置]

选中 - 如果任务已在运行,则允许按需运行任务,然后应用以下规则:不启动新实例

请帮忙。谢谢。

答案1

正如评论所指出的那样,如果您在屏幕上看不到该窗口,则无法向其发送消息。

尝试使用ControlSend不需要窗口处于活动状态的语句。我还没有测试下面的代码……也许你可以试试。该WinExist()语句获取新创建的记事本窗口的 ID……如果你打开了多个窗口,那么你需要划定哪个窗口,并在推导时更加小心,但这对于记事本根本没有运行然后你启动窗口的测试用例很有用。WinWait在这种情况下,你也可以用 sleep 语句替换它。

run Notepad.exe
sleep 1000
ControlSend,, test, % "ahk_id" WinExist("ahk_exe notepad.exe")
return

相关内容