当我断开本地桌面时,远程桌面上的 Autohotkey 不起作用

Autohotkey on a remote desktop does not work when I disconnect my local desktop

我正在使用 Autohotkey 在我的 Microsoft Azure 提供的虚拟机上每十分钟重新运行一次 Pytest。 我的 .ahk 脚本很简单。

loop
{
Send !{F10}
Sleep, 600000
}

当我连接到远程桌面时,脚本运行良好。但是,如果我退出全屏或断开连接。,它不起作用。 Autohotkey 保持 运行 但由于某种原因只是没有注册 Send !{F10}。它只在我重新连接时才开始注册。请帮忙

Autohotkey not functioning properly on minimized virtual machines 是一个已经存在一段时间的问题,

(关于虚拟机):

RemoteAdmin server process launches a program on request of remote user (you). So R.A. is a parent process for AHK. Once you minimize your RA session client it signals the RA-server that. RA-server thinks now that since the client is minimized it does not need anything and to consume CPU power it halts any activity of itself and its child processes. -wOxxOm

以及其他AHK函数的文档中,如WinActivate

Known issue: If the script is running on a computer or server being accessed via remote desktop, WinActivate may hang if the remote desktop client is minimized. One workaround is to use commands which don't require window activation, such as ControlSend and ControlClick. Another possible workaround is to apply the following registry setting on the local/client computer:

; Change HKCU to HKLM to affect all users on this system.
RegWrite REG_DWORD, HKCU, Software\Microsoft\Terminal Server Client
    , RemoteDesktop_SuppressWhenMinimized, 2

^^上述注册表更改也可能解决您的问题^^

论坛帖子针对此问题提供了几种不同的解决方法,但如果您只是想在计算机上执行其他操作时将 VM 放在一边,最不花哨的解决方案我能想到的 是通过使用 Win+[=27= 将主机上的虚拟机 window 移动到虚拟桌面]Tab 快捷键或按 using this guide。通过将 window 移动到虚拟桌面,虚拟机将以不会最小化的方式移开,允许它继续 运行 AHK 脚本。此外,您可以使用 Ctrl+Win+ 和 [=27] 在虚拟桌面之间快速导航=]Ctrl+Win+快捷键.