KeyDown

Jan 5, 2011 at 4:00 PM

I have a small wpf/xaml/c# app made of a on screen numberpad with arrows.

I need to simulate holding the key down for the arrows and can only get it to happen once per press.

It is hosted on touch screen windows xp machines.

Currently I am trying to add handlers for left mouse down and up, and use isKeyDown/SimulateKeyDown and vice versa.

Attached is a code example for the right arrow...

// in OnActivated
btnRight.AddHandler(Control.MouseLeftButtonDownEvent, new MouseButtonEventHandler(btnRight_Down), true);

btnRight.AddHandler(Control.MouseLeftButtonUpEvent, new MouseButtonEventHandler(btnRight_Up), true);		

// in event handles section
private void btnRight_Down(object sender, RoutedEventArgs e) {
    if (!InputSimulator.IsKeyDown(VirtualKeyCode.RIGHT)) InputSimulator.SimulateKeyDown(VirtualKeyCode.RIGHT);
}
private void btnRight_Up(object sender, RoutedEventArgs e) {
    if (InputSimulator.IsKeyDown(VirtualKeyCode.RIGHT)) InputSimulator.SimulateKeyUp(VirtualKeyCode.RIGHT);
}
You push/hold the left mouse btn on the right arrow of the osk app and it just moves once. We need it to keep moving until the left mouse (or touch screen users finger) is lifted.
Is this desired functionality what the SimulateKeyDown/Up methods are for? 
Coordinator
Jan 24, 2011 at 1:32 AM
Hi,
I'm sorry for the delay. What you'll need to do is implement your own timer/keyboard-repeat functionality in the application itself. If you look at the implementation of the WPF On Screen Keyboard (related to the InputSimulator project) it has a key repeat built in (from memory).
Kind Regards,
Mike

On Thu, Jan 6, 2011 at 2:00 AM, zcatton <notifications@codeplex.com> wrote:

From: zcatton

I have a small wpf/xaml/c# app made of a on screen numberpad with arrows.

I need to simulate holding the key down for the arrows and can only get it to happen once per press.

It is hosted on touch screen windows xp machines.

Currently I am trying to add handlers for left mouse down and up, and use isKeyDown/SimulateKeyDown and vice versa.

Attached is a code example for the right arrow...

// in OnActivated
btnRight.AddHandler(Control.MouseLeftButtonDownEvent, new MouseButtonEventHandler(btnRight_Down), true);

btnRight.AddHandler(Control.MouseLeftButtonUpEvent, new MouseButtonEventHandler(btnRight_Up), true);		

// in event handles section
private void btnRight_Down(object sender, RoutedEventArgs e) {
    if (!InputSimulator.IsKeyDown(VirtualKeyCode.RIGHT)) InputSimulator.SimulateKeyDown(VirtualKeyCode.RIGHT);
}
private void btnRight_Up(object sender, RoutedEventArgs e) {
    if (InputSimulator.IsKeyDown(VirtualKeyCode.RIGHT)) InputSimulator.SimulateKeyUp(VirtualKeyCode.RIGHT);
}
You push/hold the left mouse btn on the right arrow of the osk app and it just moves once. We need it to keep moving until the left mouse (or touch screen users finger) is lifted.
Is this desired functionality what the SimulateKeyDown/Up methods are for? 

Read the full discussion online.

To add a post to this discussion, reply to this email (inputsimulator@discussions.codeplex.com)

To start a new discussion for this project, email inputsimulator@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com