public void SetKeybind(string key) { var keybindOld = Keybind; try { Keybind = key.ToCharArray()[0].ToString().ToUpper(); // http://www.pinvoke.net/default.aspx/user32/MapVirtualKey.html _VirtualKeyCode = (SendInputWrapper.ScanCodeShort)SendInputWrapper.MapVirtualKey((uint)(Keys)Enum.Parse(typeof(Keys), _Keybind, true), 0x00); log.Info("Changed keybind to " + Keybind); } catch (Exception e) { log.Debug("Unable to set keybind: " + e.Message); Keybind = keybindOld; } }
private SendInputWrapper.ScanCodeShort GetScanCode(Keys key) { return((SendInputWrapper.ScanCodeShort)SendInputWrapper.MapVirtualKey((uint)key, 0x00)); }