public static void MouseDown(IntPtr ParentHandle, IntPtr Handle, int X, int Y, MouseButton Button, MouseKeyModifier Keys) { bool hooked = false; WaitToBeVisibleAndEnabled(Handle); if (!WaitForInputIdle(Handle, GUI.m_APE.TimeOut)) { throw new Exception("Window did not go idle within timeout"); } Block(ParentHandle, Handle); try { TimerResolution.SetMaxTimerResolution(); ClickCommon(ParentHandle, Handle, X, Y); GUI.m_APE.AddFirstMessageAddMouseHook(Handle); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); hooked = true; MouseClick(Button, true, false, 1, Keys.HasFlag(MouseKeyModifier.Control), Keys.HasFlag(MouseKeyModifier.Shift)); GUI.m_APE.AddFirstMessageWaitForMouseState((APEIPC.MouseButton)Button, true, true); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); } catch { Reset(); //Reset the mouse blocking throw; } finally { try { if (hooked) { GUI.m_APE.AddFirstMessageRemoveMouseHook(Handle); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); } } finally { TimerResolution.UnsetMaxTimerResolution(); Unblock(); IsMouseDown = true; } } }
public static void SendKeys(GUIFocusableObject focusableObject, string text) { WaitToBeVisibleAndEnabled(focusableObject); if (!WaitForInputIdle(focusableObject.Handle, GUI.m_APE.TimeOut)) { throw new Exception("Window did not go idle within timeout"); } if (!focusableObject.HasFocus) { focusableObject.SetFocus(); } TimerResolution.SetMaxTimerResolution(); System.Windows.Forms.SendKeys.SendWait(text); TimerResolution.UnsetMaxTimerResolution(); }
private void Resize(int adjustment, Axis axis) { Rectangle splitter = GetSplitterRectangle(); int x = splitter.X + (splitter.Width / 2); int y = splitter.Y + (splitter.Height / 2); uint doubleClickTimer = (uint)SystemInformation.DoubleClickTime; Input.Block(); try { TimerResolution.SetMaxTimerResolution(); NM.SetDoubleClickTime(1); // Mouse down over the splitter base.MouseDownInternal(x, y, MouseButton.Left, MouseKeyModifier.None); switch (axis) { case Axis.X: // Move the mouse to half way to make sure the control enters dragmode Input.MouseMove(Handle, Description, x - (adjustment / 2), y, false); // Mouse up where we want the splitter base.MouseUpInternal(x - adjustment, y, MouseButton.Left, MouseKeyModifier.None); break; case Axis.Y: // Move the mouse to half way to make sure the control enters dragmode Input.MouseMove(Handle, Description, x, y - (adjustment / 2), false); // Mouse up where we want the splitter base.MouseUpInternal(x, y - adjustment, MouseButton.Left, MouseKeyModifier.None); break; } } catch when(Input.ResetInputFilter(doubleClickTimer)) { // Will never be reached as ResetInputFilter always returns false } finally { TimerResolution.UnsetMaxTimerResolution(); NM.SetDoubleClickTime(doubleClickTimer); Input.Unblock(); } }
public static void MouseSingleClick(IntPtr ParentHandle, IntPtr Handle, int X, int Y, MouseButton Button, MouseKeyModifier Keys) { bool hooked = false; WaitToBeVisibleAndEnabled(Handle); if (!WaitForInputIdle(Handle, GUI.m_APE.TimeOut)) { throw new Exception("Window did not go idle within timeout"); } IsMouseDown = false; uint DoubleClickTimer = (uint)SystemInformation.DoubleClickTime; Block(ParentHandle, Handle); try { TimerResolution.SetMaxTimerResolution(); NM.SetDoubleClickTime(1); ClickCommon(ParentHandle, Handle, X, Y); GUI.m_APE.AddFirstMessageAddMouseHook(Handle); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); hooked = true; MouseClick(Button, true, false, 1, Keys.HasFlag(MouseKeyModifier.Control), Keys.HasFlag(MouseKeyModifier.Shift)); GUI.m_APE.AddFirstMessageWaitForMouseState((APEIPC.MouseButton)Button, true, true); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); // Some controls don't like it if the mouse is released too quick (For instance Listview // group selecting) but rather than slowing all clicks down put specific code in the problematic // control to handle it (see SelectGroup in ListView.cs for an example) MouseClick(Button, false, true, 1, Keys.HasFlag(MouseKeyModifier.Control), Keys.HasFlag(MouseKeyModifier.Shift)); GUI.m_APE.AddFirstMessageWaitForMouseState((APEIPC.MouseButton)Button, false, true); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); } catch { NM.SetDoubleClickTime(DoubleClickTimer); //Reset double click timer Reset(); //Reset the mouse blocking throw; } finally { try { if (hooked) { GUI.m_APE.AddFirstMessageRemoveMouseHook(Handle); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); } } finally { TimerResolution.UnsetMaxTimerResolution(); NM.SetDoubleClickTime(DoubleClickTimer); Unblock(); } } }
public static void MouseUp(IntPtr ParentHandle, IntPtr Handle, int x, int y, MouseButton Button, MouseKeyModifier Keys) { bool hooked = false; WaitToBeVisibleAndEnabled(Handle); Block(ParentHandle, Handle); try { NM.tagPoint thePoint = new NM.tagPoint(); thePoint.x = x; thePoint.y = y; IntPtr TopLevelHandle = NM.ChildWindowFromPoint(NM.GetDesktopWindow(), thePoint); NM.tagRect WindowSize; NM.GetWindowRect(Handle, out WindowSize); thePoint.x = x + WindowSize.left; thePoint.y = y + WindowSize.top; IntPtr ChildHandle = NM.WindowFromPoint(thePoint); if (!WaitForInputIdle(ChildHandle, GUI.m_APE.TimeOut)) { throw new Exception("Window did not go idle within timeout"); } IntPtr ActualParent; if (ParentHandle == IntPtr.Zero) { ActualParent = Handle; } else { ActualParent = ParentHandle; } TimerResolution.SetMaxTimerResolution(); //TODO this looks wrong should use clickcommon only for this if (ChildHandle == ActualParent) { ClickCommon(ParentHandle, Handle, x, y); } else { MouseMove(Handle, x, y, false); } if (Handle == ActualParent) { GUI.m_APE.AddFirstMessageAddMouseHook(Handle); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); hooked = true; } MouseClick(Button, false, true, 1, Keys.HasFlag(MouseKeyModifier.Control), Keys.HasFlag(MouseKeyModifier.Shift)); if (Handle == ActualParent) { GUI.m_APE.AddFirstMessageWaitForMouseState((APEIPC.MouseButton)Button, false, true); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); } } catch { Reset(); //Reset the mouse blocking throw; } finally { try { if (hooked) { GUI.m_APE.AddFirstMessageRemoveMouseHook(Handle); GUI.m_APE.SendMessages(EventSet.APE); GUI.m_APE.WaitForMessages(EventSet.APE); } } finally { TimerResolution.UnsetMaxTimerResolution(); Unblock(); IsMouseDown = false; } } }