Earlier this week, a user emailed support with a problem. The issue was they just couldn't get Skyrim to work with Keyboard Mapper. The mouse was fine, but no matter what they did, keyboard events wouldn't register. Unfortunately, this is a problem with a few games, and it's due to how they handle keyboard input. We support most applications with our implementation, but not all, and there are all sorts of (mutually incompatible) tricks one would have to do to add support for various other games.
It got me thinking though. Is there a workaround? Software like AutoHotKey lets you create your own hotkeys. It's really for making complicated keyboard macros, but there's no reason you can't make a simple mapping where one button triggers another. Normally that wouldn't be very useful, but if we could set the hotkey to be triggered at the level Myo Connect sends them, and then send a command at the level Skyrim is listening at... we might have something.
Spoiler: It works. Grab it in the Myo Market here.
For this week's #MyoCraft, we have a Skyrim script that works in combination with an AutoHotKey script to control the game. The Skyrim Myo Script itself is just a tweaked version of the Counter Strike script. You can get it here. You'll need Skyrim itself, of course, and AutoHotKey. Luckily, AHK is free.
What's interesting is the AHK script:
#NoEnv #SingleInstance force #UseHook #InputLevel 0 #IfWinActive ahk_exe TESV.exe [:: SendInput i Return ]:: SendInput m Return #IfWinActive
Now, there is a lot of crazy stuff you can do with AHK, and to get a script working on a particular game you may need to experiment. Every game seems to have it's own quirks, and that's before you even get into potential cheat detection. The above works for Skyrim, however.
I encourage you to read the documentation, but let's break this down so you can modify it yourself,
The commands at the start that start with
# are directives. They basically flip switches in AutoHotKey to enable or disable certain modes. #NoEnv improves performance and #SingleInstance force keeps us from having multiple instances of the script running. They are optional for our purposes. The first one we really need is #UseHook. This changes how hotkeys get registered so they get detected in Skyrim. Setting #InputLevel 0 lets the keypresses coming from our Connector still trigger the hotkey. Finally, #IfWinActive ahk_exe TESV.exe is just like implementing onForegroundWindowChange to only work with certain applications. Our AHK script will only be active when Skyrim is in the foreground.
After that, we just have the actual hotkey definitions:
[:: SendInput i Return
What this does is turn
[ into a hotkey that actually presses
i when it's triggered. You can create new ones by specifying different keyboard buttons before the double colons.
SendInput is a method of sending keyboard presses. There are a few different ones AHK supports. SendInput seems to be the most reliable for games.
Return just ends the command.
As I said, this works for Skyrim, but you may need to experiment to get it working with other games. Check this forum post for more tips.
Did you get a game working with AutoHotKey, or use AHK with Myo to do something cool? Let us know in the comments!
Otherwise, see you next week!