tags:

views:

59

answers:

2

In specific time period, when user presses "C" I want it to happen as user presses "Ctrl+C". Actually, whatever key user presses the program should adds Ctrl with it.

DO you know how to do that .NET ?

I've look around for changing KeyEventArgs.KeyData but it cannot be set.

+5  A: 

KeyEventArgs.KeyData represents what they user actually pressed.

You can create a new KeyEventArgs with the KeyData you want and pass that around.

Oded
And this got five votes?
Will
@Will, I honestly don't see your point.
Kyle Rozendo
how to pass around a new KeyEventArgs?
eig
@eig - How do you use KeyData? Where in your code? Perhaps you can update you question with some code samples, so people can explain better.
Oded
A: 

Uses this if you want to send keys:

using System;

namespace System.Windows.Forms
{
    // Summary:
    //     Provides methods for sending keystrokes to an application.
    public class SendKeys
    {
        // Summary:
        //     Processes all the Windows messages currently in the message queue.
        public static void Flush();
        //
        // Summary:
        //     Sends keystrokes to the active application.
        //
        // Parameters:
        //   keys:
        //     The string of keystrokes to send.
        //
        // Exceptions:
        //   System.InvalidOperationException:
        //     There is not an active application to send keystrokes to.
        //
        //   System.ArgumentException:
        //     keys does not represent valid keystrokes
        public static void Send(string keys);
        //
        // Summary:
        //     Sends the given keys to the active application, and then waits for the messages
        //     to be processed.
        //
        // Parameters:
        //   keys:
        //     The string of keystrokes to send.
        public static void SendWait(string keys);
    }
}
Icono123