• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1289
  • Last Modified:

Trigger double key CTRL key press in Windows C#

I have an application that starts a job when CTRL key is pressed twice. For a test, i am trying to simulate the keypress from a C# console application so that the main application can process the key strokes and start the job

The issue I am having is if I have the application start the job when a single CTRL key is pressed, it works fine. However if I have the application to start the job when two CTRL keys are pressed, the job does not start (i.e. app does not get the trigger)

I am testing on Windows 8, using the Win32 API keybd_event

Here is the code snippet

        keybd_event(VK_LCONTROL,0x9d,0 , 0);

       keybd_event(VK_LCONTROL,0x9d,0 , 0);

I suspect this to be some timing issue... Can any expert point out how i can do this differently?

Karthik K Rishi
1 Solution
Mike TomlinsonMiddle School Assistant TeacherCommented:
You could put a small pause in-between the keystrokes:

kkrishiAuthor Commented:
Thanks, that did the trick
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now