Jump to content
Sign in to follow this  
needelsjg

Lock Screen

Recommended Posts

needelsjg

I'm trying to lock the screen at the end of the script, but I can't get the (LWIN or RWIN) and the L to work at the same time.

I've tried:

Send, {LWIN} L

Send, {LWIN L}

Send, {{LWIN} L}

Send, {LWINDOWN}

Send, L

Send, {LWINUP}

I've tried it in v3 also but cant get it to work. How would you do it?

Share this post


Link to post
Share on other sites
LxP

Oops, this is the v2 support forum! :">

I don't use AutoIt v2, but I can tell you that in v3 the correct code would be:

send("#l")

I don't think that v2 has the ability to send Win+ shortcuts (in the same fashion as Ctrl+ etc.) but I could be wrong.

Windows may not allow emulation of this key (I know it doesn't allow emulation of Ctrl+Alt+Del and some others). In such a case, looking at the MSDN reference, if you upgrade to AutoIt v3 beta you would the ability to make Windows system calls. I can't test this here but perhaps something like this would work (in v3):

dllCall("user32.dll", "none", "LockWorkstation")

Share this post


Link to post
Share on other sites
needelsjg

Thanks. the send("#l") works. the dllCall... isn't working. Why does the # sign work in place of the Windows key?

Share this post


Link to post
Share on other sites
LxP

Because the key combination you are trying to send uses the Windows key as a modifier. Just like you can't save a document by pressing/releasing Ctrl and then pressing/releasing S, you cannot ask Windows to lock the computer by pressing/releasing Win and then pressing/releasing L.

Share this post


Link to post
Share on other sites
w0uter

your l is capitalised (L)

in the first script. make it small and it should work.

Send, {LWINDOWN}
Send, l
Send, {LWINUP}

but i suggest using v3 since it is more powerfull.


My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites
Bi0haZarD

dllCall("user32.dll", "none", "LockWorkstation")
just incase anyone searches for this later and cant get this to work. the s in WorkStation is capitalized.

so it would be...

dllCall("user32.dll", "none", "LockWorkStation")
Edited by Bi0haZarD

Share this post


Link to post
Share on other sites
LxP

Thanks for sharing this -- I didn't realise that capitalisation of routine was so important! I'll remember this for next time.

Share this post


Link to post
Share on other sites
needelsjg

I typed it that way for "read-ability" I had tried as many combos as I could including the lowercase "L" but it wouldn't work for me. Did you try it and get it to work?

I have since changed my script to AU3.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.