/// <summary> /// Simulates mouse movement by the specified distance measured as a delta from the current mouse location in pixels. /// </summary> /// <param name="pixelDeltaX">The distance in pixels to move the mouse horizontally.</param> /// <param name="pixelDeltaY">The distance in pixels to move the mouse vertically.</param> public static void MoveMouseBy(int pixelDeltaX, int pixelDeltaY) { WindowsInput.InputSimulator sim = new WindowsInput.InputSimulator(); //sim.Mouse.MoveMouseTo(absoluteX, absoluteY); //sim.Mouse.MoveMouseTo(10000, 10000); sim.Mouse.MoveMouseBy(pixelDeltaX, pixelDeltaY); }
static void Main() { var sim = new InputSimulator(); var args = Environment.GetCommandLineArgs(); if (args.Length < 2) { sim.Keyboard .ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_G); return; } switch (args[1].ToUpperInvariant()) { case "S": sim.Keyboard .Sleep(1000) .ModifiedKeyStroke(new VirtualKeyCode[] { VirtualKeyCode.LWIN, VirtualKeyCode.MENU }, VirtualKeyCode.SNAPSHOT); break; case "R": sim.Keyboard .Sleep(1000) .ModifiedKeyStroke(new VirtualKeyCode[] { VirtualKeyCode.LWIN, VirtualKeyCode.MENU }, VirtualKeyCode.VK_R); break; case "G": sim.Keyboard .Sleep(1000) .ModifiedKeyStroke(new VirtualKeyCode[] { VirtualKeyCode.LWIN, VirtualKeyCode.MENU }, VirtualKeyCode.VK_G); break; } }
static void Main(string[] args) { Console.WriteLine("Running..."); Console.WriteLine("Press esc to quit after random wait."); var random = new Random((int)DateTime.Now.Ticks); var sleepTime = random.Next(10000, 60000); var nextKey = random.Next(0, 4); var keys = new List<VirtualKeyCode> { VirtualKeyCode.SPACE, VirtualKeyCode.VK_W, VirtualKeyCode.VK_A, VirtualKeyCode.VK_S, VirtualKeyCode.VK_D }; var nextKeyTime = random.Next(500, 1000); var simulator = new InputSimulator(); do { while (!Console.KeyAvailable) { simulator.Keyboard.KeyDown(keys[nextKey]); Thread.Sleep(nextKeyTime); simulator.Keyboard.KeyUp(keys[nextKey]); Console.WriteLine("Random wait time {0} ms, press key {1} for {2} ms", sleepTime, keys[nextKey], nextKeyTime); Thread.Sleep(sleepTime); sleepTime = random.Next(1000, 60000); nextKey = random.Next(0, 4); nextKeyTime = random.Next(500, 1000); } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); }
public Response HandleRequest(Request request) { PresentationControls control = (PresentationControls)Convert.ToInt32(request.RequestedParameters[0]); InputSimulator sim = new InputSimulator(); switch (control) { //start the presentation with F5 case PresentationControls.StartPresentation: sim.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.F5 }); break; //stop the presentation with ESC case PresentationControls.StopPresentation: sim.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.ESCAPE }); break; //next slide is arrow right case PresentationControls.Next: sim.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.RIGHT }); break; //previous is arrow left case PresentationControls.Previous: sim.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.LEFT }); break; default: break; } return new Response(TCPStatusCodes.Ok); }
static void TestMouseMoveTo() { var sim = new InputSimulator(); sim.Mouse.MoveMouseTo(0, 0); Thread.Sleep(1000); sim.Mouse.MoveMouseTo(65535, 65535); Thread.Sleep(1000); sim.Mouse.MoveMouseTo(65535 / 2, 65535 / 2); }
public void SearchInTheDocument(string theSearchString) { this.axAcroPdf.Select(); this.axAcroPdf.Focus(); InputSimulator test = new InputSimulator(); test.Keyboard.ModifiedKeyStroke(WindowsInput.Native.VirtualKeyCode.CONTROL, WindowsInput.Native.VirtualKeyCode.VK_F); test.Keyboard.TextEntry(theSearchString); test.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RETURN); }
private void KeepFocus(object sender, EventArgs e) { WindowsInput.InputSimulator sim = new WindowsInput.InputSimulator(); double winx = this.Left; double winy = this.Top; sim.Mouse.MoveMouseTo(winx + 100, winy + 100); sim.Mouse.LeftButtonClick(); sim.Mouse.MoveMouseTo(1000,65535); }
public KinectStickEngine(CompiledProfile profile) { actualNode = null; instructionQueue = new List<CompiledSpeechPhrase>(); joy = new VJoyWrapper(); inputSimulator = new InputSimulator(); this.profile = profile; ready = InitKinect() && LoadSpeechRecognitionEngine(); }
public CommandState() { inputsim = SharedObjectsSingleton.Instance().inputSimulator; commandList = SettingsSingleton.Instance().Commands; zoomForm = SharedFormsSingleton.Instance().zoomForm; scrollManager = new ScrollManager(); keyboardManager = new KeyboardManager(); toastOverlay = SharedFormsSingleton.Instance().ToastOverlay; }
public KeyCombo(string keysString, InputSimulator inputSimulator) { Keys = new List<VirtualKeyCode>(); this.inputSimulator = inputSimulator; foreach (string VARIABLE in keysString.Split(',')) { var keyCode = KeyTranslater.GetKeyCode(VARIABLE); Keys.Add(keyCode); } }
public WiiKeyMap(JObject jsonObj, string configName, string configFilename, XinputDevice xinput, XinputReport xinputReport) { this.Name = configName; this.Filename = configFilename; this.jsonObj = jsonObj; this.inputSimulator = new InputSimulator(); this.XinputDevice = xinput; this.XinputReport = xinputReport; xinput.OnRumble += Xinput_OnRumble; }
public ZoomForm() { InitializeComponent(); formGraphics = panel1.CreateGraphics(); bmp = new Bitmap(Width, Height); g = Graphics.FromImage(bmp); //Getting the input simulator from the shared objects this.inputSim = SharedObjectsSingleton.Instance().inputSimulator; this.Visible = false; }
public MainWindow() { InitializeComponent(); if(Properties.Settings.Default.Port != -1) this.tbPort.Text = Properties.Settings.Default.Port.ToString(); this.tbPassword.Text = Properties.Settings.Default.Password; Console.WriteLine("Nome computer :" + System.Environment.MachineName); btnStart.IsEnabled = true; inputSimulator = new InputSimulator(); refreshGuiAtInitialization(); }
// Use this for initialization IEnumerator Start() { wAnimationWindowHelper.init(); inputSimulator = new WindowsInput.InputSimulator(); /* * var activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene(); //現在のシーンを取得 * string activeSceneName = activeScene.name; * if (activeSceneName == string.Empty) * { * activeSceneName = "Untitled"; * } * getWindowObject.GetComponent<uWindowCapture.UwcWindowTexture>().partialWindowTitle = activeSceneName; //ウインドウ名には現在のシーン名が含まれてるハズなので指定 * * yield return null; //ウインドウが更新されるのを待つ * * int waitCount = 0; * while (waitCount < 300) * { * if (getWindowObject.childCount == 0) * { * waitCount++; * yield return null; * } * else * { * break; * } * } * * if (getWindowObject.childCount == 0) * { * Debug.Log("Unityエディタの子ウインドウが見つかりません"); * yield break; * } * * var child = getWindowObject.GetChild(0);//最初の子がアニメーションビューだと決めてかかって取得 * var material = child.GetComponent<MeshRenderer>().sharedMaterial; //マテリアル取得 * childWindow = child.GetComponent<uWindowCapture.UwcWindowTexture>(); * Debug.Log("title:" + childWindow.window.threadId); * * setWindowObject.GetComponent<MeshRenderer>().sharedMaterial = material;//取得したマテリアルをセット * * getWindowObject.GetComponent<uWindowCapture.UwcWindowTexture>().captureRequestTiming = uWindowCapture.WindowTextureCaptureTiming.Manual;//もうUnity本体のウインドウは更新不要 */ while (targetRawImage.texture == null) { yield return(null); } init = true; }
public KinectKeyStroke() { simulator = new InputSimulator(); isKeyHeld = false; keyMap = new VK_MAP(); if (hwnd.Equals(IntPtr.Zero)) { MessageBox.Show("Please check your setting ,make sure the window name is correct!"); Environment.Exit(0); //throw new InvalidOperationException("The name of the minecraft window is not correct, or the minecraft game is not launched. Please check your settings."); } }
// Use this for initialization IEnumerator Start() { wAnimationWindowHelper.init(); inputSimulator = new WindowsInput.InputSimulator(); var activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene(); //現在のシーンを取得 string activeSceneName = activeScene.name; if (activeSceneName == string.Empty) { activeSceneName = "Untitled"; } getWindowObject.GetComponent <uWindowCapture.UwcWindowTexture>().partialWindowTitle = activeSceneName; //ウインドウ名には現在のシーン名が含まれてるハズなので指定 yield return(null); //ウインドウが更新されるのを待つ int waitCount = 0; while (waitCount < 300) { if (getWindowObject.childCount == 0) { waitCount++; yield return(null); } else { break; } } if (getWindowObject.childCount == 0) { Debug.Log("Unityエディタの子ウインドウが見つかりません"); yield break; } var child = getWindowObject.GetChild(0); //最初の子がアニメーションビューだと決めてかかって取得 var material = child.GetComponent <MeshRenderer>().sharedMaterial; //マテリアル取得 childWindow = child.GetComponent <uWindowCapture.UwcWindowTexture>(); Debug.Log("title:" + childWindow.window.threadId); setWindowObject.GetComponent <MeshRenderer>().sharedMaterial = material; //取得したマテリアルをセット getWindowObject.GetComponent <uWindowCapture.UwcWindowTexture>().captureRequestTiming = uWindowCapture.WindowTextureCaptureTiming.Manual; //もうUnity本体のウインドウは更新不要 init = true; }
public DictationState() { inputsim = SharedObjectsSingleton.Instance().inputSimulator; toast = SharedFormsSingleton.Instance().ToastOverlay; if (SettingsSingleton.Instance().DragonEnabled) { dictation = new DragonDictation(); } else { dictation = new WindowsDictation(); } Settings.Default.PropertyChanged += CheckState; }
public static async Task ChangeScreen() { Console.WriteLine("Screen: " + SCREEN_NUMBER); var i = new WindowsInput.InputSimulator(); var key = SCREEN_NUMBER == 1 ? VirtualKeyCode.F2 : VirtualKeyCode.F3; i.Keyboard.KeyDown(VirtualKeyCode.LCONTROL); i.Keyboard.KeyDown(VirtualKeyCode.LWIN); i.Keyboard.KeyDown(VirtualKeyCode.LMENU); i.Keyboard.KeyDown(key); i.Keyboard.Sleep(50); i.Keyboard.KeyUp(key); i.Keyboard.KeyUp(VirtualKeyCode.LMENU); i.Keyboard.KeyUp(VirtualKeyCode.LWIN); i.Keyboard.KeyUp(VirtualKeyCode.LCONTROL); }
protected override void InternalExecute(ICommandAdapter adapter){ var focusWindowCommand=new FocusWindowCommand(); focusWindowCommand.Execute(adapter); var sleepCommand = new SleepCommand(); sleepCommand.Parameters.MainParameter = new MainParameter("300"); sleepCommand.Execute(adapter); var simulator=new InputSimulator(); if (!string.IsNullOrEmpty(Parameters.MainParameter.Value)) simulator.Keyboard.TextEntry(Parameters.MainParameter.Value); var keysParameter = Parameters["Keys"]; if (keysParameter != null){ foreach (var key in keysParameter.Value.Split(';')){ var keyCode = (VirtualKeyCode) Enum.Parse(typeof (VirtualKeyCode), key); simulator.Keyboard.KeyPress(keyCode); } } }
static void AnotherTest() { var sim = new InputSimulator(); sim.Keyboard.KeyPress(VirtualKeyCode.SPACE); sim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R); Thread.Sleep(1000); sim.Keyboard.TextEntry("mspaint"); Thread.Sleep(1000); sim.Keyboard.KeyPress(VirtualKeyCode.RETURN); Thread.Sleep(1000); // Paint sim.Mouse.LeftButtonDown(); sim.Mouse.MoveMouseToPositionOnVirtualDesktop(65535 / 2, 65535 / 2); sim.Mouse.LeftButtonUp(); }
public MainWindow() { InitializeComponent(); this.sensor = KinectSensor.GetDefault(); this.sensor.Open(); this.inputSimulator = new InputSimulator(); this.kinectCursor = new KinectSystemCursor( sensor, new SimpleActiveBodySelector(), new CummulativeMovingAverageFilter(), new DoubleExponentialSmoothingFilter(0.4f, 0.5f), 0.2f); this.kinectCursor.CursorMoved += KinectCursor_CursorMoved; this.kinectCursor.LeftMouseDown += KinectCursor_LeftMouseDown; this.kinectCursor.LeftMouseUp += KinectCursor_LeftMouseUp; }
public MainEngine() { sharedData = SharedDataSingleton.Instance(); _settingsList = SettingsSingleton.Instance(); inputSimulator = sharedData.inputSimulator; controlState = new ControlContext(); controlState.changedState += StateChanged; controlState.ControlState = new CommandState(inputSimulator, controlState); //System.Diagnostics.Process.Start("C:/Program Files (x86)/Nuance/NaturallySpeaking13/Program/natspeak.exe"); SetupSpeechRecognition(); //Instantiating and starting the eye tracker host eyex = new EyeXHost(); eyex.CreateFixationDataStream(FixationDataMode.Sensitive).Next += (s, e) => Fixation(e.EventType, (int)e.X, (int)e.Y, e.Timestamp); eyex.Start(); }
public void SimulateDif(KeyboardState oldstate) { HashSet<Keys> oldkeys = new HashSet<Keys>(oldstate._pressedKeys); HashSet<Keys> newkeys = new HashSet<Keys>(_pressedKeys); newkeys.ExceptWith(oldstate._pressedKeys); oldkeys.ExceptWith(_pressedKeys); InputSimulator iss = new InputSimulator(); foreach (Keys key in oldkeys) { iss.Keyboard.KeyUp((VirtualKeyCode)(int)key); } foreach (Keys key in newkeys) { iss.Keyboard.KeyDown((VirtualKeyCode)(int)key); } }
private void keyboardHook1_KeyboardHooked(object sender, HongliangSoft.Utilities.Gui.KeyboardHookedEventArgs e) { //Console.WriteLine(e.KeyCode); a = e.KeyCode.ToString(); if (c != 1) { if (b == 0) { //左移動 if (a == Properties.Settings.Default.Leftkey) { //Console.WriteLine("F9キーが押されました。"); var sim = new InputSimulator(); sim.Keyboard.ModifiedKeyStroke( new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.LWIN }, VirtualKeyCode.LEFT ); b = 1; } //右移動 if (a == Properties.Settings.Default.Rightkey) { var sim = new InputSimulator(); sim.Keyboard.ModifiedKeyStroke( new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.LWIN }, VirtualKeyCode.RIGHT ); b = 1; } } else { b = 0; } } }
public static void Read() { InputSimulator input = new InputSimulator(); while (running) { try { string message = serial.ReadLine(); if (message.Equals("toggle\r")) { input.Keyboard.KeyPress(VirtualKeyCode.VK_R); Console.WriteLine("Red Alert Toggled"); } } catch(TimeoutException) { } } }
static void Main(string[] args) { var fileIniDataParser = new FileIniDataParser(); _configuracoes = new Configuracoes(fileIniDataParser); _mapaDeComandos = _configuracoes.MapaDeComandos; _serialPort = new SerialPort(_configuracoes.Porta, 9600, Parity.None, 8, StopBits.One) { Handshake = Handshake.None, WriteTimeout = 500 }; _serialPort.DataReceived += AoReceberMensagem; _serialPort.Open(); _inputSimulator = new InputSimulator(); while (true) { } }
public void Execute() { try { Logger.Info("Locating wolfpack console, process id = {0}...", _instruction.ProcessId); var console = Process.GetProcessById(_instruction.ProcessId); Logger.Info("Process located...sending close message"); Thread.Sleep(3000); var isFront = SetForegroundWindow(console.MainWindowHandle); if (!isFront) { Logger.Warning("Unable to make Wolfpack console the foreground window, trying again..."); isFront = SetForegroundWindow(console.MainWindowHandle); if (!isFront) { Logger.Warning("Still unable to make Wolfpack console the foreground window, please manually restart wolfpack!"); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); return; } } Thread.Sleep(1000); var sim = new InputSimulator(); sim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C); Logger.Info("Close message sent, waiting for process to exit"); WaitForApplicationToClose(console); StartApplication(); } catch (Exception e) { Logger.Error(Logger.Event.During("RestartConsoleCommand.Execute").Encountered(e)); throw; } }
public bool Gestured(PointInfo actionPoint) { if (_settings == null) return false; InputSimulator simulator = new InputSimulator(); try { var referencePoint = GetReferencePoint(_settings.ClickPosition, actionPoint); switch (_settings.MouseAction) { case MouseActions.HorizontalScroll: simulator.Mouse.HorizontalScroll(_settings.ScrollAmount); return true; case MouseActions.VerticalScroll: simulator.Mouse.VerticalScroll(_settings.ScrollAmount); return true; case MouseActions.MoveMouseTo: MoveMouse(simulator, _settings.MovePoint); return true; case MouseActions.MoveMouseBy: referencePoint.Offset(_settings.MovePoint); MoveMouse(simulator, referencePoint); break; default: { MoveMouse(simulator, referencePoint); MethodInfo clickMethod = typeof(IMouseSimulator).GetMethod(_settings.MouseAction.ToString()); clickMethod.Invoke(simulator.Mouse, null); break; } } } catch { return false; } return true; }
public bool Gestured(PointInfo ActionPoint) { try { if (ActionPoint.WindowHandle.ToInt64() != ManagedWinapi.Windows.SystemWindow.ForegroundWindow.HWnd.ToInt64()) ManagedWinapi.Windows.SystemWindow.ForegroundWindow = ActionPoint.Window; if (_useSendInput) { InputSimulator simulator = new InputSimulator(); simulator.Keyboard.TextEntry(_keystrokes); } else { System.Windows.Forms.SendKeys.SendWait(_keystrokes); } return true; } catch { return false; } }
public WiimoteControl(int id, Wiimote wiimote) { this.Wiimote = wiimote; this.Status = new WiimoteStatus(); this.Status.ID = id; lastpoint = new CursorPos(0,0,0); this.screenBounds = Util.ScreenBounds; ulong touchStartID = (ulong)(id - 1) * 4 + 1; //This'll make sure the touch point IDs won't be the same. DuoTouch uses a span of 4 IDs. this.duoTouch = new DuoTouch(this.screenBounds, Properties.Settings.Default.pointer_positionSmoothing, touchStartID); this.keyMapper = new WiiKeyMapper(id); this.keyMapper.OnButtonDown += WiiButton_Down; this.keyMapper.OnButtonUp += WiiButton_Up; this.keyMapper.OnConfigChanged += WiiKeyMap_ConfigChanged; this.keyMapper.OnRumble += WiiKeyMap_OnRumble; this.inputSimulator = new InputSimulator(); this.screenPositionCalculator = new ScreenPositionCalculator(); this.useCustomCursor = Settings.Default.pointer_customCursor; if (this.useCustomCursor) { Color myColor = CursorColor.getColor(this.Status.ID); this.masterCursor = new D3DCursor((this.Status.ID-1)*2,myColor); this.slaveCursor = new D3DCursor((this.Status.ID-1)*2+1,myColor); masterCursor.Hide(); slaveCursor.Hide(); D3DCursorWindow.Current.AddCursor(masterCursor); D3DCursorWindow.Current.AddCursor(slaveCursor); this.keyMapper.SendConfigChangedEvt(); } }
public DragonDictation() { inputSimulator = SharedObjectsSingleton.Instance().inputSimulator; StartDragon(); }
public KeyboardHandler() { this.inputSimulator = new InputSimulator(); this.keysDown = new HashSet<VirtualKeyCode>(); }
public CmdExeApi() { Input_Simulator= new InputSimulator(); PipeName = 64000.random().str(); // give it a random name FullPipeName = @"\\.\pipe\"+ PipeName; ProcessToStart = "cmd"; // default Arguments = ""; MinimizeHostWindow = true; ConsoleOut = (text) => text.info(); }
public KeyboardConsumer() : base() { singleStroke = false; keymappings = new BindingList<Keymapping>(); InitKeys(); _converter = new MovCodeToStringConverter(); _movsToKeyCodes = new Dictionary<int, VirtualKeyCode>(); _keyboardControl = new KeyboardControl(); _keyboardControl.viewModel.keyboardConsumer = this; consumerControl = new BaseControl(); ((BaseControl)consumerControl).viewModel.realtimeConsumer = this; ((BaseControl)consumerControl).itemsGrid.Children.Clear(); ((BaseControl)consumerControl).itemsGrid.Children.Add(_keyboardControl); _simulator = new InputSimulator(); //UpdateKeymappings(); keymappings.ListChanged += keymappings_ListChanged; //Configuring a timer that will call the Keystroke method each 100 milliseconds. _timer = new FastTimer(3, 100, Keystroke); }