Solved

simulate alt, ctrl and shift-keys

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - CSV to Oracle table 4 51
Visual Studio editor? 1 37
Exit the loop 4 22
VB.Net - Windows UserName index and length error 4 17
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

947 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

21 Experts available now in Live!

Get 1:1 Help Now