Sign in to follow this  
Followers 0
Seminko

Sending a key combination to a locked PC

16 posts in this topic

Hey fellas,

we use VM at work. The annoying part is that when you want to lock the VM you have to click the VM menu, click "Send Ctrl Alt Del", click Lock. Because if you just click it manually it will bring up the desktop menu, not the VM menu (note the desktop cannot be locked by itself, they disabled it for some reason).

So instead of that I use:

Run("rundll32.exe user32.dll,LockWorkStation")

However, even though we use W7, when you lock the PC you don't the see classic screen with the input to write the password in. There is a screen saying sth like "This PC is locked, to unlock it press Ctrl Alt Del". And again, the only way to do that manually is moving your mouse up to the VM menu etc etc. This gets annoying like pretty fast since I'm running around the office constantly and have to lock my PC every time.

My question is: is it possible to somehow do that by a script? I mean sending a Ctrl + Alt + Del to a locked computer? From what I read in the last hour, ControlSend should work, however I have NO IDEA how to get the controlID. Tried a few example scripts which should list all available controls for an active window but the locked screen didn't seem to support that.

Also, does HotKeySet even work on a locked screen?

Any ideas?

Very much appreciated!

Share this post


Link to post
Share on other sites



Sending CTRL+ALT+DEL is blocked, for obvious reasons, as stated very clearly in the help file:

Quote

N.B. Windows does not allow the simulation of the "CTRL-ALT-DEL" combination!

 


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

13 minutes ago, JLogan3o13 said:

Sending CTRL+ALT+DEL is blocked, for obvious reasons, as stated very clearly in the help file:

 

Alright, fair enough. Any ideas on how to achieve what I'm after?

Edited by Seminko

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Alright, so one step closer. When the VM is locked, I am able to press Ctrl + Alt + Pause/Break to show the VM menu, where I can press double down arrow, and enter and the password screen opens.

Now what I need to know is how to ControlSend that key combination to the locked screen.

Edited by Seminko

Share this post


Link to post
Share on other sites

Try sending CTRL+ALT+I, most VMs and RDC boxes use that instead of CAD.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
2 hours ago, BrewManNH said:

Try sending CTRL+ALT+I, most VMs and RDC boxes use that instead of CAD.

The PCs we use are set up in a way that all documents are wiped after shutdown so this has to run on the VM istelf. How do I ControlSend that when the VM is locked? How do I even check for the control since I cannot run the window info utility when it's locked. And also as mentioned above, I tried scripts that should list all the controls on the active window but with no avail, nothing is returned when the PC is locked.

Share this post


Link to post
Share on other sites

So, I'm going to come in and put my Mod hat on. You have what sounds like non-persistent VDI desktops set up that are resetting to the golden image when you log out. If you need to keep documents, and you are the administrator, why are you not doing that instead of this attempt to get around it?


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites
5 hours ago, Seminko said:

The PCs we use are set up in a way that all documents are wiped after shutdown so this has to run on the VM istelf. How do I ControlSend that when the VM is locked? How do I even check for the control since I cannot run the window info utility when it's locked. And also as mentioned above, I tried scripts that should list all the controls on the active window but with no avail, nothing is returned when the PC is locked.

So you have a script running on a VM, the actual VM the script is running on is locked, and you want to unlock the locked VM from behind the login screen?


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
4 hours ago, JohnOne said:

So you have a script running on a VM, the actual VM the script is running on is locked, and you want to unlock the locked VM from behind the login screen?

Maybe I just suck at explaining my issue. So let me give it another shot.

We work on VMs, however this VM does not have the usual Ctrl + Alt + End key combination which other VMs have which sends Ctrl + Alt + Del to the VM. So the only way for me to lock or unlock the VM is by clicking with my mouse on the VM menu, clicking 'send Ctrl + Alt + Del' and then clicking 'Lock this PC'. This I have a workaround for --> I created a windows shortcut with 'rundll32.exe user32.dll,LockWorkStation' which locks the VM with one click. Great, problem solved.

Now, the unlocking is as well pretty much annoying. Again, manual mouseclick on the VM menu, clicking 'send Ctrl + Alt + Del', pressing enter which then shows the login screen to put my password in. And since the VM menu runs actually on the PC itself, when the password screen opens I have manually click the password input box to be able to write there. To focus the window actually.

What I want is a script that would run on the VM on a while loop waiting for a hotkey press and once pressed it would send Ctrl + Alt + Pause/Break (this shows another VM menu) + plus double down arrow + plus enter, to the active window (which at that point is the locked VM screen). This makes the VM show the login screen to put my pass in without the need to click it with the mouse as the window still remains active. That way I could just press a hotkey, and put the pass in manually, saving me like three clicks.

Guys, if I'm not exaplaining it well, just ask for specifics.

Thanks

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Virtual

Edited by Seminko

Share this post


Link to post
Share on other sites

#12 ·  Posted

Then I'm quite sure you cannot break out of the virtual environment to affect it.

Take VM out of the story, and try to write a script to unlock screen after you press win+l.

If you can do that, then you might get somewhere.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#13 ·  Posted

That's it, I don't want to break out of the VM environment, obviously :). I mentioned the VM just so you guys know why I need what I need.

2 hours ago, JohnOne said:

Take VM out of the story, and try to write a script to unlock screen after you press win+l.

If you can do that, then you might get somewhere.

That was my starting point as well, but I failed hard. From what I read on the forum it is certainly possible for a script send clicks and keys to a locked screen however those have to be ControlClicks. Or did I completely misread it and it was meant to send ControlClicks to an application even though the screen was locked? So I tried but fel short because I didn't have the control id, not sure if I need one but it certainly seems so. I tried the good old Send but that didn't work at all either.

Share this post


Link to post
Share on other sites

#14 ·  Posted

The locked screen operates on a different desktop session from where your script is running.

The reason you cannot accomplish your goal is directly because of this security measure.

I'm not saying it is not possible, just that windows does not want to allow it.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#15 ·  Posted

16 hours ago, JohnOne said:

The locked screen operates on a different desktop session from where your script is running.

Could you ellaborate? I guess it's just the terminology again. But the script is running on the same desktop session. I mean, as you said, let's forget there is a VM, does your comment still stand?

If it's really that hard, then I'll drop it. Just want to make sure...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0