Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simulating Ctrl-Alt-Del

Posted on 2003-11-17
5
Medium Priority
?
1,982 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
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 750 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

926 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