Solved

simulate alt, ctrl and shift-keys

Posted on 2007-03-31
2
968 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 85

Accepted Solution

by:
Mike Tomlinson earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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