?
Solved

simulate alt, ctrl and shift-keys

Posted on 2007-03-31
2
Medium Priority
?
978 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
[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
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

777 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