Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simulating Ctrl-Alt-Del

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

722 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