Question

I'm trying to send virtual button presses to an app. I tried using SendKeys.Send("{6}");, but the app receives it like a string or something similar because it doesn't act. The app I want to send the key to is VisualBoy Advance. My code simply allows me to play remotely using a GUI, so when I press left on the GUI the VBA should receive the keystroke.

A part of the code:

case "derecha":
    SendKeys.SendWait("{4}");
    break;
Was it helpful?

Solution

The { and } characters are special escape characters. I don't think 6 is an escape value. Have a look at http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx for the known escapes. For example, SendKeys.SendWait("{Right}"); would send a right arrow key.

However,

Many games and emulators will be using low level keyboard hooks to read the keyboard state. It's quite rare to find games that use the Windows events model for keyboard reading. SendKeys only sends to the Windows messaging system. You may need a more low-level way of sending events.

If the target app is using DirectInput, you might be able to use the SendInput function from user32.dll:

There is also the Interception library, but I've never used it myself:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top