![如何让自动热键脚本在桌面锁定后继续运行?](https://linux22.com/image/1569093/%E5%A6%82%E4%BD%95%E8%AE%A9%E8%87%AA%E5%8A%A8%E7%83%AD%E9%94%AE%E8%84%9A%E6%9C%AC%E5%9C%A8%E6%A1%8C%E9%9D%A2%E9%94%81%E5%AE%9A%E5%90%8E%E7%BB%A7%E7%BB%AD%E8%BF%90%E8%A1%8C%EF%BC%9F.png)
我有一个自动热键脚本
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Recommended for catching common errors.
SendMode Event ; Input worked hardly, "Event" is better.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 1 ; 1: A window's title must start with the specified WinTitle to be a match.
#IfWinActive Zooming Viewer
~RButton & WheelDown::
Send {Ctrl Down} {WheelUp} {Ctrl Up}
return
~RButton & WheelUp::
Send {Ctrl Down} {WheelDown} {Ctrl Up}
return
參考文獻:如何让自动热键将“右按钮按下,鼠标滚轮动作,右按钮向上”转换为“左按钮按下,鼠标上下移动,左按钮向上”
如何让此脚本在 Win-7 上不受桌面锁定影响?释放锁定的计算机后,查看器的行为就像没有 AHK 脚本一样。单击通知区域中的脚本菜单,选择“重新加载此脚本”可使其再次工作 - 但强制这样做似乎有点烦人。
答案1
尝试
#Warn ; Recommended for catching common errors.
SendMode Event ; Input worked hardly, "Event" is better.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 1 ; 1: A window's title must start with the specified WinTitle to be a match.
MsgBox, Reloading
OnMessage(0x2b1,"WM_WTSSESSION_CHANGE")
Gui,+LastFound
hwnd:=WinExist()
DllCall("Wtsapi32.dll\WTSRegisterSessionNotification","UInt",hwnd,"UInt",0)
Return
#IfWinActive Zooming Viewer
~RButton & WheelDown::
Send {Ctrl Down} {WheelUp} {Ctrl Up}
return
~RButton & WheelUp::
Send {Ctrl Down} {WheelDown} {Ctrl Up}
return
#IfWinActive
WM_WTSSESSION_CHANGE(wParam,lParam){
static _0x1:="WTS_CONSOLE_CONNECT" ;A session was connected to the console terminal.
; ,_0x2:="WTS_CONSOLE_DISCONNECT" ;A session was disconnected from the console terminal.
; ,_0x3:="WTS_REMOTE_CONNECT" ;A session was connected to the remote terminal.
; ,_0x4:="WTS_REMOTE_DISCONNECT" ;A session was disconnected from the remote terminal.
,_0x5:="WTS_SESSION_LOGON" ;A user has logged on to the session.
; ,_0x6:="WTS_SESSION_LOGOFF" ;A user has logged off the session.
; ,_0x7:="WTS_SESSION_LOCK" ;A session has been locked.
,_0x8:="WTS_SESSION_UNLOCK" ;A session has been unlocked.
; ,_0x9:="WTS_SESSION_REMOTE_CONTROL" ;A session has changed its remote controlled status. To determine the status, call GetSystemMetrics and check the SM_REMOTECONTROL metric.
Reload
}