private static VirtualKeyCode DoRemap(VirtualKeyCode inputKey, ButtonStates movement) { if (Tube.KeyMap != null && Tube.KeyMap.TryGetValue(inputKey, out KeyboardRemapEntry remap)) { // Filter remapping to the given process name // If empty process name is given, perform remap for all of them string inputFocusProcessName = ""; if (remap.ProcessName != null && remap.ProcessName.Length != 0) { inputFocusProcessName = ProcessInfo.GetProcessFileName( ProcessInfo.GetInputFocusProcessId()); LOGGER.Debug( "DoRemap inputKey = [" + inputKey + "] focus window = [" + inputFocusProcessName + "] remap process = [" + remap.ProcessName + "]"); if (!inputFocusProcessName .ToLower() .Contains(remap.ProcessName.ToLower()) ) { return(inputKey); } } LOGGER.Debug("REMAPPED: " + inputKey + " -> " + remap.KeyCodeNew); ActionKey actionKey = new ActionKey(TimeProvider.GetTickCount(), remap.KeyCodeNew, movement); actionKey.Play(); return(remap.KeyCodeNew); } return(inputKey); }
private void SimulateKey(int keyCode, ButtonStates buttonState) { ActionKey actionKey = new ActionKey(TimeProvider.GetTickCount(), (VirtualKeyCode)keyCode, buttonState); actionKey.Play(); }