protected override void OnMouseMove(MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { Point pt = Cursor.Position; IntPtr childWindow = WindowFromPoint(pt); WindowInfo CurWindow = new WindowInfo(GetAncestor(childWindow, GA_ROOT)); if(CurWindow.Equals(LastWindow) == false) OnWindowOver(new WindowSelect_EventArgs(CurWindow)); if (LastWindow == null) { ControlPaint.DrawReversibleFrame(CurWindow.Rect, WindowOutlineColor, WindowOutlineFrameStyle); } else if (CurWindow.Equals(LastWindow) == false) { ControlPaint.DrawReversibleFrame(LastWindow.Rect, WindowOutlineColor, WindowOutlineFrameStyle); ControlPaint.DrawReversibleFrame(CurWindow.Rect, WindowOutlineColor, WindowOutlineFrameStyle); } LastWindow = CurWindow; Cursor.Current = Cursors.Cross; } base.OnMouseMove(e); }
public async Task Play(WindowInfo[] windows) { try { _Playing = true; bool firstStep = true; DateTime lastStep = DateTime.Now; foreach(KeyValuePair<DateTime, KeyboardEventInfo> kvp in _Sequence) { if (firstStep == true) { firstStep = false; } else { await Task.Delay( (kvp.Key - lastStep) ); } lastStep = kvp.Key; foreach (WindowInfo i in windows) { kvp.Value.Replay(i.Handle); //KB.Forms.frmMain.WriteLog(string.Format("REPLAY : {0} - {1:X} - {2:X}", ((System.Windows.Forms.Keys)kvp.Value.m_Key).ToString(), kvp.Value.m_Msg, kvp.Value.lParam)); } } _Playing = false; } catch { throw; } }
protected override void OnMouseUp(MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (LastWindow != null) { ControlPaint.DrawReversibleFrame(LastWindow.Rect, WindowOutlineColor, WindowOutlineFrameStyle); Cursor.Current = Cursors.Arrow; OnWindowSelect(new WindowSelect_EventArgs(LastWindow)); LastWindow = null; } } base.OnMouseUp(e); }
public WindowSelect_EventArgs(WindowInfo info) { _info = info; }
private void KeyboardListener_s_KeyEventHandler(object sender, EventArgs e) { try { KeyboardListener.UniversalKeyEventArgs eventArgs = (KeyboardListener.UniversalKeyEventArgs)e; KeyboardEventInfo kei = new KeyboardEventInfo(eventArgs); if (Config.Current.IgnoredKeys.Contains((int)eventArgs.m_Key)) return; WindowInfo curWindow = new WindowInfo(GetForegroundWindow()); if (_Windows.Contains(curWindow) == true) { if (Active == true) { //WriteLog(string.Format("SEND : {0} - {1:X} - {2:X}", ((Keys) kei.m_Key).ToString(), kei.m_Msg, kei.lParam)); foreach (WindowInfo i in _Windows) { if (i.Equals(curWindow) == false) kei.PostMessage(i.Handle); } } if (_Recorder != null && _Recorder.Recording == true) { //WriteLog(string.Format("RECORD : {0} - {1:X} - {2:X}", ((Keys)kei.m_Key).ToString(), kei.m_Msg, kei.lParam)); _Recorder.Add(kei); } } } catch (Exception ex) { Utils.ShowError(ex); } }