private void TryRegisterHotkey(string name, BindingKeysData value) { Mod.Debug(MethodBase.GetCurrentMethod(), name, HotkeyHelper.GetKeyText(value)); if (value != null) { HotkeyHelper.RegisterKey(name, value, KeyboardAccess.GameModesGroup.All); } else { HotkeyHelper.UnregisterKey(name); } }
private bool ReadersInit(string sProfName) { bool bSetVK, bRet = false; do {// MHL drivers hKeyb = new MHLDriver(); try { hKeyb.Open("Keyboard"); } catch (Exception ex) { throw new Exception("Клавиатура не открыта!"); } // Hotkey capture hotkeyHelper = new HotkeyHelper(); hScan = new MHLDriver(); try { hScan.Open("Scanner"); bRet = hScan.SetDword("Scanner.Timeout", 5); bSetVK = hKeyb.SetDword("Keyboard.ScanMode", 0); bSetVK = hKeyb.SetDword("SpecialKey.Scan.All.VK", BarCodeScanKey); } catch (Exception ex) { throw new Exception("Сканер не открыт!"); } if (RFIDScanKey > 0) { hRfid = new MHLDriver(); try { hRfid.Open("RFID"); } catch (Exception ex) { throw new Exception("RFID Driver failure: " + ex.ToString()); } if (hRfid.IsOpen()) { try { //hRfid.SetString("RFID.TagType", "EPC C1G2"); } catch (Exception ex) { throw new Exception("RFID Ttype failure: " + ex.ToString()); } } } if (hKeyb.IsOpen()) { // Save current keyboard map hKeyb.SaveProfile(sProfName); // Map "Scan" button to VK_F12 (0x7B) if (RFIDScanKey > 0) { //hKeyb.SetDword("SpecialKey.Square.All.VK", 0); if (base.nTermType == TERM_TYPE.NRDMERLIN) { bool bn = hKeyb.SetDword("SpecialKey.Circle.All.VK", RFIDScanKey); } } // Reload map hKeyb.SetDword("Keyboard.Reload", 1); } hotkeyHelper.SetCallbackDelegate(new HotkeyHelper.HotkeyCallback(HandleScanKey)); // Register BarCodeScanKey as global hotkey hotkeyHelper.RegisterKey(BarCodeScanKey, KeyModifiers.None); //hkHelperRFID = new HotkeyHelper(); //hkHelperRFID.SetCallbackDelegate(new HotkeyHelper.HotkeyCallback(HandleRFIDScanKey)); //hkHelperRFID.RegisterKey(RFIDScanKey, KeyModifiers.None); bRet = true; } while (false); return(bRet); }