Solved

Simulating Ctrl-Alt-Del

Posted on 2003-11-17
5
1,957 Views
Last Modified: 2008-03-03
I have been trying to simulate a Ctrl+Alt+Del keypress for a Macro program that I am writing.  So far I have tried using the combination of the three using keybd_event, with no success.  I am trying to get through a screen saver (WINNT) which requires me to hit Ctlr-Alt-Del to get to the user/password prompt.

My Macro program has to interact with the GUI (running as a scheduled task), but I want to protect the computer with user passwords and screensaver passwords.  The only way I have been able to figure being able to run this program with the GUI is to also automate the login, and to "break through" the screen saver by automating as well.

I have not been able to find a way to automate a login, but I think I should be able to break through the screen saver.
0
Comment
Question by:Masurium
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9764190
Hm, I think this is the wrong approach.

>>I have not been able to find a way to automate a login

Why do you need to automate the login? Have the program run as a service.

>>I should be able to break through the screen saver

Kill the screeensaver using 'TerminateProcess()'.
0
 
LVL 4

Accepted Solution

by:
Ichijo earned 250 total points
ID: 9767865
Q234562 in MSDN (http://support.microsoft.com/default.aspx?scid=kb;en-us;234562) explains how to automate the login process. But it probably won't much help for screen savers. However, this presents a security risk, as probably would automating a login with ctrl-alt-del.

Also take a look at Q140723 (http://support.microsoft.com/default.aspx?scid=kb;en-us;140723).
0
 

Author Comment

by:Masurium
ID: 9768671
Actually, since I have to both create the security, (and apparently for this macro automation, break through it) I have already modified the default user registry in win95 and win98 machines to force the computer to shutdown if a non-valid user attempts to logon, rather than them be created as a new default user.  So, the security breach is too high.

Thanks for the idea anyways.
0
 
LVL 2

Expert Comment

by:xssass
ID: 9957587

you can use the winapi function kbd_event. it works in combination with virtual key codes...

the statement "keybd_event(VK_CONTROL, 0, 0, 0);" whould simulate a press of the ctrl key.
"keybd_event(VK_CONTROL,0, KEYEVENTF_KEYUP, 0);" whould simulate a release of the ctrl key.

the first argument identifies the key.
the second argument is not used.
the third argument denodes a press or a release.
the last argument specifies an additional value associated with the key stroke.

(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/KeyboardInputFunctions/keybd_event.asp)

So for your particular purpose it should be:

keybd_event(VK_CONTROL,0,0,0);         // Control key press
keybd_event(VK_MENU,0,0,0);               // Alt key press
keybd_event(VK_DELETE,0,0,0);            // Delete key press

keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);         // Control key release
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);               // Alt key release
keybd_event(VK_DELETE,0,KEYEVENTF_KEYUP,0);            // Delete key release

Don't forget to #include <windows.h>

Hope this helps...
  .K.
0
 

Author Comment

by:Masurium
ID: 9958790
Thanks, but that was my initial approach.  See the initial question.  I stated: "So far I have tried using the combination of the three using keybd_event, with no success".  Apparently the OS is catching this before it executes for security reasons, basically to prevent exactly what I'm trying to do.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question