using keybd_event() function in C$#

Posted on 2007-07-29
Last Modified: 2012-06-27
How to use the function    keybd_event(); in C#  which fiels need to be included;  please provide a
short example, I am getting syntax errors,  

Question by:amielDorel
    LVL 3

    Expert Comment

    Your best bet would be to use the SendKeys class to send keyboard
    strokes to your application.
    LVL 5

    Expert Comment

    Here's one I use for KeyUp

    /// <summary>
                /// Raises the KeyUp event
                /// </summary>
                /// <param name="e">A KeyEventArgs that contains the event data</param>
                protected override void OnKeyUp(KeyEventArgs e)

                      if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Enter)
                            this.Collapsed = !this.Collapsed;

    LVL 85

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 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

    12 Experts available now in Live!

    Get 1:1 Help Now