我正在尝试将 WinLock 重新映射到新的东西。基本上我想删除 Win+L 以锁定 Windows 并添加 Win+L 以打开要打开的特定程序。任何帮助?谢谢。
PS:目前我使用 #L::Run "C:\Program Files\program.exe" 返回打开一个程序,但它也锁定了工作站。我在注册表中找到了一种方法来禁用 Win+L 锁定 Windows 的功能,但是我不想编辑注册表,所以我很好奇是否可以使用 autohotkey 来完成?
AHK 无法拦截这些 Windows 快捷方式。如果您不想编辑注册表值,我认为没有办法做到这一点。注册表值是HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System: DisableLockWorkstation,如果 1 将禁止完全锁定系统,无论是否有快捷方式,而 0 锁定是允许的,无论什么尝试拦截它,快捷方式 Win+L 都将锁定系统。评论(对于那些正在寻找有效的 Win+L 解决方案但不知道 AHK 的人)代码:
使用注册表编辑:
; WARNING: Programs that use User32\LockWorkStation (i.e. programmatically locking the operating system) may not work correctly!
; This includes Windows itself (i.e. using start menu or task manager to lock will also not work).
; Script changes Win-L to show a msgbox and Ctrl-Alt-L to lock windows
; The following 3 code lines are auto-executed upon script run, the return line marks an end to the auto-executed code section.
; Register user defined subroutine 'OnExitSub' to be executed when this script is terminating
OnExit, OnExitSub
; Disable LockWorkStation, so Windows doesn't intercept Win+L and this script can act on that key combination
SetDisableLockWorkstationRegKeyValue( 1 )
return
#l::
MsgBox, Win-L was pressed! ; Arbitrary code here
return
^!l::
; Ctrl-Alt-L
; Temporary enable locking
SetDisableLockWorkstationRegKeyValue( 0 )
; Lock
DllCall( "User32\LockWorkStation" )
; Disable locking again
SetDisableLockWorkstationRegKeyValue( 1 )
return
OnExitSub:
; Enable LockWorkStation, because this script is ending (so other applications aren't further disturbed)
SetDisableLockWorkstationRegKeyValue( 0 )
ExitApp
return
SetDisableLockWorkstationRegKeyValue( value )
{
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Policies\System, DisableLockWorkstation, %value%
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2376 次 |
| 最近记录: |