?
Solved

simulate alt, ctrl and shift-keys

Posted on 2007-03-31
2
Medium Priority
?
983 Views
Last Modified: 2008-02-01
Hello

I have the following code, but when I use Alt = True, Ctrl = True and Key = Keys.Delete, I do not get the Taskmanager which you should get with ALT, CTRL and DELETE

What is wrong?

   Private Sub DoKeyBoard(ByVal Shift As Boolean, ByVal alt As Boolean, ByVal ctrl As Boolean, ByVal key As Keys)
        Dim KEYEVENTF_KEYUP As Byte = &H2
        If ctrl = True Then
            keybd_event(Keys.ControlKey, 0, 0, 0)              
        End If
        If alt = True Then
            keybd_event(18, 0, 0, 0)            
        End If
        If Shift = True Then
            keybd_event(Keys.ShiftKey, 0, 0, 0)              
        End If
        keybd_event(key, 0, 0, 0)            
        keybd_event(key, 0, KEYEVENTF_KEYUP, 0)
        If Shift = True Then
            keybd_event(Keys.ShiftKey, 0, KEYEVENTF_KEYUP, 0)
        End If
        If alt = True Then
            keybd_event(18, 0, KEYEVENTF_KEYUP, 0)
        End If
        If ctrl = True Then
            keybd_event(Keys.ControlKey, 0, KEYEVENTF_KEYUP, 0) ' Generates a KEY_UP
        End If
    End Sub
0
Comment
Question by:Ruttensoft
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1500 total points
ID: 18830433
You can't generate a Ctrl-Alt-Del combination in this manner.

It is handled by the kernel at a much lower level.

If it was that easy to bring up the task manager it would be a snap to fool the user into typing in their password while your keyboard logger records everything!

To do this you would basically need to write your own GINA.DLL to handle SAS requests:
http://msdn2.microsoft.com/en-us/library/aa380543.aspx

What are you trying to do here?...
0
 

Author Comment

by:Ruttensoft
ID: 18830559
Ok thanks, thats ok.

Actually I am creating a remote control with my POcketPC, and I just wanted to test if the CTRL, ALT and SHIFT-Keys are working correctly. I have now simulated other keystrokes (Ctrl + Esc, Alt + F4) and that is working... Just thought that my code is not working for simulating keystrokes...

Thanks

Sven
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

862 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