locking my screen not with Win L Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

locking my screen not with Win L

05 Nov 2019, 09:48

how can I lock my screen with a single shortcut?

the following is not working:

Code: Select all

#a::DllCall("LockWorkStation")
Last edited by AmDeG 11 on 13 Nov 2019, 15:30, edited 2 times in total.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: locking my screen

05 Nov 2019, 15:32

I re-design Win 1 to another purpose...

if someone can help me out with the code
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: locking my screen

05 Nov 2019, 15:49

DllCall("LockWorkStation") works here.

You might want to reconsider reassigning Win L (which is the native Windows shortcut for locking the PC).
I re-design Win 1 to another purpose...
I presume you meant Win l rather than win 1.
14.3 & 1.3.7
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: locking my screen

05 Nov 2019, 16:04

Try this:

Code: Select all

#a::#l
(as flyingDman pointed out, that's a lower case L, not the number 1)
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: locking my screen

07 Nov 2019, 20:59

I overrode the native shortcut #l to be another thing

for that reason I would like to know the way to execute locking screen with another # key
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: locking my screen

07 Nov 2019, 21:26

AmDeG 11 wrote:
07 Nov 2019, 20:59
I overrode the native shortcut #l to be another thing
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.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: locking my screen

08 Nov 2019, 11:54

interesting comment

I disabled from here

http://www.howtogeek.com/howto/windows-vista/disableenable-lock-workstation-functionality-windows-l/

If I enable it, is there another way to move locking screen to ANOTHER WINDOW KEY so as to have Win L for another purpose?
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: locking my screen

08 Nov 2019, 13:04

What you showed is why I asked how you accomplished that. Apparently the reason that DllCall("LockWorkStation") is not working for you is that you disabled the ability to lock the workstation altogether when you edited the registry. It can't be locked by using Win+L, not via the Start menu, , not via Ctrl+Alt+Delete, and not by the DllCall. It won't lock no matter what key it is assigned to because the function has been disabled. I know it's not the answer you want, but it seems to be the reason for what is happening.

If you enable it, the Win+L combination appears to be always captured by Windows to lock the workstation. At least from what I can see, you can assign a hotkey to it, but it will also lock the workstation. That's why I asked how you were able to reassign it without having it also lock.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: locking my screen

08 Nov 2019, 17:27

ok I got it

so is there any no solution?

can I reasign Lockstation to another key and use Win L for another purpose?

maybe a somewhat similar function to Lockstation that can temporarily freeze my machine?
Last edited by AmDeG 11 on 08 Nov 2019, 17:34, edited 1 time in total.
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: locking my screen

08 Nov 2019, 17:33

You can assign it to another key like this:
#a::#l
and you can assign a hotkey to #l, but it will perform the hotkey code in addition to locking the workstation. Perhaps someone else knows away to intercept the key at a lower level such that Windows won't see it and lock it, but I don't know how.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: locking my screen

08 Nov 2019, 18:21

but as long as Win L continues locking the computer I cannot see any purpose to try to have it done another action
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: locking my screen

08 Nov 2019, 19:18

Yes, exactly. Unless someone else knows a way to do it, it looks like you would just have to leave it as is.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: locking my screen

13 Nov 2019, 12:29

does anyone know a way to simulate the function LockScreen been disabled the default Win L shortcut?
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: locking my screen

13 Nov 2019, 12:35

If it is disabled using the method shown in the link you have given, you are not disabling the Win+L shortcut, you are disabling the ability for LockScreen to be performed by any method at all, including keyboard shortcuts, DLL calls, via the start menu, via Ctrl+Alt+Delete, or any other method. There will be no way to invoke a LockScreen when you have disabled it in that manner.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: locking my screen not with Win L

13 Nov 2019, 15:32

ok, imagine I enabled (delete disable) Win L

now, how can I force Win L to be Right Arrow and Win S to be LockScreen ?
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: locking my screen

13 Nov 2019, 16:15

To quote my earlier post:
boiler wrote:
08 Nov 2019, 13:04
If you enable it, the Win+L combination appears to be always captured by Windows to lock the workstation. At least from what I can see, you can assign a hotkey to it, but it will also lock the workstation.
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.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: locking my screen not with Win L

14 Nov 2019, 21:18

Boiler,
I asked to OTHER people that MIGHT have a solution. I know that you don't have it. However, at your answer you even expressed that MAYBE another could have a solution, saying: "At least from what I can see [it is not possible]"

thanks!
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: locking my screen not with Win L  Topic is solved

21 Nov 2019, 02:53

Changing the DisableLockWorkstation value to 1, in the registry, disables the Win+L hotkey, but appears to have the side effect of disabling all means of locking the workstation.

With Win+L disabled, you can choose an alternative hotkey to lock the workstation. It needs to set DisableLockWorkstation to 0, call LockWorkStation, and then set DisableLockWorkstation to 1.

The script below will run smoothly if run as admin. Otherwise you have to respond to 2 run as admin prompts.

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
If there is *some way* to lock the workstation, even when DisableLockWorkstation is set to 1, that would be interesting. Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
eugenesv
Posts: 174
Joined: 21 Dec 2015, 10:11

Re: locking my screen not with Win L

05 Jun 2020, 15:21

jeeswg wrote:
21 Nov 2019, 02:53
[/code]
If there is *some way* to lock the workstation, even when DisableLockWorkstation is set to 1, that would be interesting. Cheers.
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.
  • Name: WinLock Disable
  • Run with highest privileges check mark set
  • Actions: start a program(this is the default)
  • Program/script: REG
  • Add arguments: ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v DisableLockWorkstation /t REG_DWORD /d 00000001 /f
and
  • Name: WinLock Enable
  • Run with highest privileges check mark set
  • Actions: start a program(this is the default)
  • Program/script: REG
  • Add arguments: ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v DisableLockWorkstation /t REG_DWORD /d 00000000 /f
(by the way, instead of manually creating the second task it might be easier to export the first, edit the command in the text editor and then import it with a new name, might save a clik :) )

Then you would adjust your script to execute:

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"')

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 216 guests