Solved

Simulating Ctrl-Alt-Del

Posted on 2003-11-17
5
1,928 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 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now