public static void SetText(Point point, string textToSet) { var helperAutomation = new HelperAutomation(); IntPtr windowFromPoint = helperAutomation.WindowFromPoint(point); SetText(windowFromPoint, textToSet); }
public static string GetText(Point point) { var helperAutomation = new HelperAutomation(); IntPtr windowFromPoint = helperAutomation.WindowFromPoint(point); return(GetText(windowFromPoint)); }
public static void SetText(string text) { var automation = new HelperAutomation(); IntPtr focusControlHandle = automation.GetFocusControlHandle(); SetText(focusControlHandle, text); }
public static bool KillFocus() { var helperAutomation = new HelperAutomation(); var focusControlHandle = helperAutomation.GetFocusControlHandle(); Win32Declares.Message.SendMessage(focusControlHandle, Win32Constants.Focus.WM_KILLFOCUS, IntPtr.Zero, IntPtr.Zero); return(helperAutomation.GetFocusControlHandle() != focusControlHandle); }
/// <summary> /// paste clipbard data /// </summary> /// <param name="mainWindowHandle">the widbow that contains the control in which the data is going to be pasted</param> public static void PasteFromClipBoard(IntPtr mainWindowHandle) { WindowAutomation.ForceWindowToForeground(mainWindowHandle); var helperAutomation = new HelperAutomation(); IntPtr focusControlHandle = helperAutomation.GetFocusControlHandle(); Win32Declares.Message.SendMessage(focusControlHandle, Win32Constants.Clipboard.WM_PASTE, IntPtr.Zero, IntPtr.Zero); }
/// <summary> /// default timeout is 5000 millisec /// </summary> /// <param name="windowCaption"></param> /// <returns>0 if window not found</returns> public static IntPtr WaitForWindowToOpen(string windowCaption) { var helperAutomation = new HelperAutomation(); if (findWindowsWithTimeout(helperAutomation, windowCaption)) { IntPtr findWindow = Win32Declares.WindowHandles.FindWindow(null, windowCaption); return(findWindow); } return(IntPtr.Zero); }
private static bool findWindowsWithTimeoutHandler(HelperAutomation helperAutomation, string windowCaption) { while (true) { helperAutomation.FindAllWindows(null); if (helperAutomation.AllWindowCaptions.Contains(windowCaption)) { return(true); } } }
private static bool findWindowsWithTimeout(HelperAutomation helperAutomation, string windowCaption) { findWindowsWithTimeoutDelegate findWindowsWithTimeoutDelegate = findWindowsWithTimeoutHandler; IAsyncResult asyncResult = findWindowsWithTimeoutDelegate.BeginInvoke(helperAutomation, windowCaption, null, null); if (!asyncResult.IsCompleted) { asyncResult.AsyncWaitHandle.WaitOne(-1, false); } return(asyncResult.IsCompleted && findWindowsWithTimeoutDelegate.EndInvoke(asyncResult)); }
public static bool ForceWindowToForeground(this IntPtr windowHandle) { if (Win32Declares.WindowFocus.GetForegroundWindow() == windowHandle) { return(true); } HelperAutomation.AttachedThreadInputAction( () => { Win32Declares.WindowFocus.SetForegroundWindow(windowHandle); Win32Declares.WindowFocus.BringWindowToTop(windowHandle); var showWindowEnum = Win32Declares.Window.IsIconic(windowHandle)? Win32Declares.Window.ShowWindowEnum.SW_RESTORE: Win32Declares.Window.ShowWindowEnum.SW_SHOW; Win32Declares.Window.ShowWindow(windowHandle, showWindowEnum); }); return(Win32Declares.WindowFocus.GetForegroundWindow() == windowHandle); }
public static void SetReadOnly() { var helperAutomation = new HelperAutomation(); SetReadOnly(helperAutomation.GetFocusControlHandle()); }
/// <summary> /// default timeout is 5000 millisec /// </summary> /// <param name="text"></param> /// <param name="windowPosition"></param> /// <returns></returns> public static bool WaitForWindowToHaveText(string text, Point windowPosition) { IntPtr intPtr = new HelperAutomation().WindowFromPoint(windowPosition); return(WaitForWindowToHaveText(text, intPtr, false)); }