the following is not working:
Code: Select all
#a::DllCall("LockWorkStation")
Code: Select all
#a::DllCall("LockWorkStation")
I presume you meant Win l rather than win 1.I re-design Win 1 to another purpose...
Code: Select all
#a::#l
I'd be interested in hearing how you did that. I'm not able to. It is supposedly protected by Windows. Did you have to use some other method than a regular remap or hotkey? Perhaps whatever you did is also the reason DllCall("LockWorkStation") isn't working for you.
You're really just asking the same questions again. It is looking like you just have to accept that as long as LockScreen capability is enabled, Windows is always going to link Win+L to it. You can link another key to locking the screen, but you can't simultaneously remove that function from Win+L.
Code: Select all
;Win+L
#l:: ;a new purpose for Win+L
MsgBox, % "a new purpose for Win+L"
return
;Ctrl+Win+Alt+L
^#!l:: ;lock workstation (note: requires 2 'run as admin' registry writes)
;tested with Windows 7
;enable 'lock workstation' (and enable Win+L hotkey):
RegRead, vIsDisabled, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System, DisableLockWorkstation
if vIsDisabled
try RunWait, % "*RunAs " A_ComSpec " /c REG ADD HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableLockWorkstation /t REG_DWORD /d 0 /f",, Hide ;enable Win+L
;RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System, DisableLockWorkstation, 0 ;enable Win+L
;lock workstation:
DllCall("user32\LockWorkStation")
;disable 'lock workstation' (and disable Win+L hotkey):
RegRead, vIsDisabled, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System, DisableLockWorkstation
if !vIsDisabled
try RunWait, % "*RunAs " A_ComSpec " /c REG ADD HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableLockWorkstation /t REG_DWORD /d 1 /f",, Hide ;disable Win+L
;RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System, DisableLockWorkstation, 1 ;disable Win+L
return
I think there is a better way where you need neither an elevated script nor two UAC prompts. The trick is creating two tasks in the Task Scheduler that would flip the bit in the registry, e.g.
Code: Select all
...
Run('schtasks /Run /TN "\PathTo\WinLock Enable"') ;\PathTo\ in case you created your tasks in a separate folder not to mix with others, "quotes" in case youre task names have spaces
...
Run('schtasks /Run /TN "\PathTo\WinLock Disable"')
Users browsing this forum: No registered users and 216 guests