public SUIWindow ClickToGetEditControl() { Click(); SUISleeper.Sleep(2000); RECT rect = Rect; int x = ListView.X + rect.left + 5; int y = ListView.Y + rect.top + 5; IntPtr handle = SUIWinAPIs.WindowFromPoint(new Point(x, y)); if (handle == null || handle.Equals(IntPtr.Zero) || handle.Equals(ListView.WindowHandle)) { throw new SUIException("No edit control found!"); } SUIWindow window = new SUIWindow(handle); while (true) { if (window.Parent == null) { throw new SUIException("No edit control found!"); } if (window.Parent.WindowHandle.Equals(ListView.WindowHandle)) { break; } window = window.Parent; } return(window); }
// Gets the Internet Explorer IHTMLDocument2 object for the given // IE Server control window handle // The class name of this window should be "Internet Explorer_Server" private static IHTMLDocument2 GetIEDocumentFromWindow(SUIWindow window) { if (!window.ClassName.Equals("Internet Explorer_Server")) throw new SUIException("Unable to get IHTMLDocument object from this window!"); IntPtr lResult; int lMsg; IHTMLDocument2 htmlDocument = null; if (window.WindowHandle != IntPtr.Zero) { // Register the WM_HTML_GETOBJECT message so it can be used // to communicate with the Internet Explorer instance lMsg = SUIWinAPIs.RegisterWindowMessage("WM_HTML_GETOBJECT"); // Sends the above registered message to the IE window and // waits for it to process it SUIWinAPIs.SendMessageTimeout(window.WindowHandle, lMsg, IntPtr.Zero, IntPtr.Zero, SUIWinAPIs.SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out lResult); if (lResult != IntPtr.Zero) { // Casts the value returned by the IE window into //an IHTMLDocument2 interface htmlDocument = SUIWinAPIs.ObjectFromLresult(lResult, typeof(IHTMLDocument).GUID, IntPtr.Zero) as IHTMLDocument2; } if (htmlDocument == null) { throw new SUIException("Unable to get IHTMLDocument object from this window!"); } } return htmlDocument; }
// Gets the Internet Explorer IHTMLDocument2 object for the given // IE Server control window handle // The class name of this window should be "Internet Explorer_Server" private static IHTMLDocument2 GetIEDocumentFromWindow(SUIWindow window) { if (!window.ClassName.Equals("Internet Explorer_Server")) { throw new SUIException("Unable to get IHTMLDocument object from this window!"); } IntPtr lResult; int lMsg; IHTMLDocument2 htmlDocument = null; if (window.WindowHandle != IntPtr.Zero) { // Register the WM_HTML_GETOBJECT message so it can be used // to communicate with the Internet Explorer instance lMsg = SUIWinAPIs.RegisterWindowMessage("WM_HTML_GETOBJECT"); // Sends the above registered message to the IE window and // waits for it to process it SUIWinAPIs.SendMessageTimeout(window.WindowHandle, lMsg, IntPtr.Zero, IntPtr.Zero, SUIWinAPIs.SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out lResult); if (lResult != IntPtr.Zero) { // Casts the value returned by the IE window into //an IHTMLDocument2 interface htmlDocument = SUIWinAPIs.ObjectFromLresult(lResult, typeof(IHTMLDocument).GUID, IntPtr.Zero) as IHTMLDocument2; } if (htmlDocument == null) { throw new SUIException("Unable to get IHTMLDocument object from this window!"); } } return(htmlDocument); }
public SUIWindow ClickToGetEditControl() { Click(); SUISleeper.Sleep(2000); RECT rect = Rect; int x = ListView.X + rect.left + 5; int y = ListView.Y + rect.top + 5; IntPtr handle = SUIWinAPIs.WindowFromPoint(new Point(x, y)); if (handle == null || handle.Equals(IntPtr.Zero) || handle.Equals(ListView.WindowHandle)) throw new SUIException("No edit control found!"); SUIWindow window = new SUIWindow(handle); while (true) { if (window.Parent == null) throw new SUIException("No edit control found!"); if(window.Parent.WindowHandle.Equals(ListView.WindowHandle)) break; window = window.Parent; } return window; }
public static SUIHtmlDocument GetSUIHtmlDocumentFromWindow(SUIWindow window) { IHTMLDocument2 doc = GetIEDocumentFromWindow(window); SUIHtmlDocument SUIDoc = new SUIHtmlDocument(doc); SUIDoc.InternetServer = window; return SUIDoc; }
public static void InitializeSMARTUI(SUIWindow sui) { int proId = 0; IntPtr winThread = SUIWinAPIs.GetWindowThreadProcessId(sui.WindowHandle, ref proId); IntPtr curThread = SUIWinAPIs.GetCurrentThreadId(); SUIWinAPIs.AttachThreadInput(curThread, winThread, 1); }
public static Point GetPositionFromTextIndex(IntPtr HWnd, string text, int index) { string processedText = text; if (SUIUtil.IsCurrentOSVista) { SUIWindow win = new SUIWindow(HWnd); if (!win.ClassName.Equals("SysListView32")) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < text.Length; i++) { char temp = (char)(text[i] - 29); builder.Append(temp); } processedText = builder.ToString(); } } Point result = new Point(-1, -1); try { SUISleeper.Sleep(2000); result = GetPointFromTextIndex(HWnd, processedText, index); } catch { Debug.WriteLine("GetPositionFromText ERROR."); } return(result); }
public static Point GetPositionFromTextIndex(IntPtr HWnd,string text, int index) { string processedText = text; if (SUIUtil.IsCurrentOSVista) { SUIWindow win = new SUIWindow(HWnd); if (!win.ClassName.Equals("SysListView32")) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < text.Length; i++) { char temp = (char)(text[i] - 29); builder.Append(temp); } processedText = builder.ToString(); } } Point result = new Point(-1, -1); try { SUISleeper.Sleep(2000); result = GetPointFromTextIndex(HWnd, processedText, index); } catch { Debug.WriteLine("GetPositionFromText ERROR."); } return result; }
public static SUIHtmlDocument GetSUIHtmlDocumentFromWindow(SUIWindow window) { IHTMLDocument2 doc = GetIEDocumentFromWindow(window); SUIHtmlDocument SUIDoc = new SUIHtmlDocument(doc); SUIDoc.InternetServer = window; return(SUIDoc); }
public static void MouseDrag(SUIWindow startWindow, int xStart, int yStart, SUIWindow endWindow, int xEnd, int yEnd) { xStart += startWindow.X; yStart += startWindow.Y; xEnd += endWindow.X; yEnd += endWindow.Y; MouseMove(xStart, yStart); SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.LEFTDOWN), (uint)xStart, (uint)yStart, 0, 0); MouseMove(xEnd, yEnd); SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.LEFTUP), (uint)xEnd, (uint)yEnd, 0, 0); }
public int FindPopupMenu(IntPtr hWnd,int lParam) { SUIWindow sui = new SUIWindow(hWnd); if ((sui != null) && (sui.ClassName.Equals("MsoCommandBarPopup"))) { popupedMenu = new SUIMsoCommandBarPopup(hWnd); return 0; } return 1; }
public int FindPopupMenu(IntPtr hWnd, int lParam) { SUIWindow sui = new SUIWindow(hWnd); if ((sui != null) && (sui.ClassName.Equals("MsoCommandBarPopup"))) { popupedMenu = new SUIMsoCommandBarPopup(hWnd); return(0); } return(1); }
private static IList <SUIWindow> TrackWinAncestors(SUIWindow actionOnSomething) { IList <SUIWindow> allAncestorsincludingSelf = new List <SUIWindow>(); while (!actionOnSomething.ClassName.Equals("#32769")) { allAncestorsincludingSelf.Add(actionOnSomething); actionOnSomething = actionOnSomething.Ancestor; } Trace.WriteLine("total parent is : " + allAncestorsincludingSelf.Count); return(allAncestorsincludingSelf); }
public static string GenerateDlgGUID(SUIDialog sui) { string DlgGUID = "NoItem"; SUIWindow firstChild = null; IntPtr ptr = SUIWinAPIs.GetWindow(sui.WindowHandle, 5); if (IntPtr.Zero.Equals(ptr)) return DlgGUID; firstChild = new SUIWindow(ptr); if (firstChild != null) { DlgGUID = firstChild.ClassName.Trim() + (uint)firstChild.WindowID + (firstChild.Width - firstChild.X); } return DlgGUID; }
public static string GetWord(SUIWindow win, Point p) { string result = string.Empty; try { IntPtr strPtr = GetTextFromPoint(win.WindowHandle, p); result = Marshal.PtrToStringAuto(strPtr); } catch { Debug.WriteLine("GetWord ERROR"); } return result; }
public static string GetWord(SUIWindow win, Point p) { string result = string.Empty; try { IntPtr strPtr = GetTextFromPoint(win.WindowHandle, p); result = Marshal.PtrToStringAuto(strPtr); } catch { Debug.WriteLine("GetWord ERROR"); } return(result); }
public int FindTargetWindow(IntPtr HWND, int lpram) { int processId = 0; SUIWinAPIs.GetWindowThreadProcessId(HWND, ref processId); if (processId == lpram) { if (SUIWinAPIs.IsWindowVisible(HWND)) { mainWindow = new SUIWindow(HWND); return 0; } } return 1; }
public int FindTargetWindow(IntPtr HWND, int lpram) { int processId = 0; SUIWinAPIs.GetWindowThreadProcessId(HWND, ref processId); if (processId == lpram) { if (SUIWinAPIs.IsWindowVisible(HWND)) { mainWindow = new SUIWindow(HWND); return(0); } } return(1); }
public static string GenerateDlgGUID(SUIDialog sui) { string DlgGUID = "NoItem"; SUIWindow firstChild = null; IntPtr ptr = SUIWinAPIs.GetWindow(sui.WindowHandle, 5); if (IntPtr.Zero.Equals(ptr)) { return(DlgGUID); } firstChild = new SUIWindow(ptr); if (firstChild != null) { DlgGUID = firstChild.ClassName.Trim() + (uint)firstChild.WindowID + (firstChild.Width - firstChild.X); } return(DlgGUID); }
public static void CaptureDialog(string fileName, ImageFormat imageFormat, SUIWindow sui) { Rectangle rDialog = new Rectangle(); SUIWinAPIs.GetWindowRect(sui.WindowHandle, out rDialog); IntPtr hdcSrc = SUIWinAPIs.GetWindowDC(sui.WindowHandle); IntPtr hdcDest = SUIWinAPIs.CreateCompatibleDC(hdcSrc); IntPtr hBitmap = SUIWinAPIs.CreateCompatibleBitmap(hdcSrc, rDialog.Width-rDialog.X, rDialog.Height-rDialog.Y); SUIWinAPIs.SelectObject(hdcDest, hBitmap); SUIWinAPIs.BitBlt(hdcDest, 0, 0, rDialog.Width-rDialog.X, rDialog.Height-rDialog.Y, hdcSrc, 0, 0, 0x00CC0020); SaveImageAs(hBitmap, fileName, imageFormat); Cleanup(hBitmap, hdcSrc, hdcDest, sui.WindowHandle); }
public static void CaptureDialog(string fileName, ImageFormat imageFormat, SUIWindow sui) { Rectangle rDialog = new Rectangle(); SUIWinAPIs.GetWindowRect(sui.WindowHandle, out rDialog); IntPtr hdcSrc = SUIWinAPIs.GetWindowDC(sui.WindowHandle); IntPtr hdcDest = SUIWinAPIs.CreateCompatibleDC(hdcSrc); IntPtr hBitmap = SUIWinAPIs.CreateCompatibleBitmap(hdcSrc, rDialog.Width - rDialog.X, rDialog.Height - rDialog.Y); SUIWinAPIs.SelectObject(hdcDest, hBitmap); SUIWinAPIs.BitBlt(hdcDest, 0, 0, rDialog.Width - rDialog.X, rDialog.Height - rDialog.Y, hdcSrc, 0, 0, 0x00CC0020); SaveImageAs(hBitmap, fileName, imageFormat); Cleanup(hBitmap, hdcSrc, hdcDest, sui.WindowHandle); }
//Sometimes, it needs a few seconds to initialize context menu and show it. //So I add a timeout parameter for this operation. public static SUIPopupMenu MouseRightClick(SUIWindow window, string strWindowsText, int x, int y, int timeout) { SUIMouse.MouseRightClick(window, x, y); SUIWindow win = null; while (win == null && timeout > 0) { SUISleeper.Sleep(200); win = SUIWindow.DesktopWindow.FindChildWindow("#32768", strWindowsText); timeout--; } if (win == null) { throw new SUIException("Fail to find context menus!"); } return(new SUIPopupMenu(win)); }
//Sometimes, it needs a few seconds to initialize context menu and show it. //So I add a timeout parameter for this operation. public static SUIMsoCommandBarPopup MouseRightClick(SUIWindow window, string strWindowsText, int x, int y, int timeout) { SUIMouse.MouseRightClick(window, x, y); SUIWindow win = null; while (win == null && timeout > 0) { SUISleeper.Sleep(200); win = SUIWindow.DesktopWindow.FindChildWindow(WindowClass, strWindowsText); timeout--; } if (win == null) { return(null); } return(new SUIMsoCommandBarPopup(win)); }
public static SUIHtmlDocument FindEmbeddedHtmlDocument(SUIWindow window) { SUIWindow docWin = null; //We need to find the window whose class name is "Internet Explorer_Server". foreach (SUIWindow win in window.Children) { if (win.ClassName.Equals("Internet Explorer_Server")) { docWin = win; break; } } if (docWin == null) { throw new SUIException("Fail to find embedded html document!"); } return GetSUIHtmlDocumentFromWindow(docWin); }
public static SUIHtmlDocument FindEmbeddedHtmlDocument(SUIWindow window) { SUIWindow docWin = null; //We need to find the window whose class name is "Internet Explorer_Server". foreach (SUIWindow win in window.Children) { if (win.ClassName.Equals("Internet Explorer_Server")) { docWin = win; break; } } if (docWin == null) { throw new SUIException("Fail to find embedded html document!"); } return(GetSUIHtmlDocumentFromWindow(docWin)); }
private int EnumControls(IntPtr ControlHandle, int lparam) { if (SUIWinAPIs.IsWindowVisible(ControlHandle)) { SUIWindow controlWindow = new SUIWindow(ControlHandle); //if (controlWindow.IsDialog) //{ // SUIWinAPIs.EnumChildWindows(ControlHandle, new EnumSMARTUIWindowsProc(EnumControls), 0); //} //else string WindowClassName = controlWindow.ClassName; if (WindowClassName.Equals("Button") || WindowClassName.Equals("Edit") || WindowClassName.Equals("ComboBox") || WindowClassName.Equals("Static") || WindowClassName.StartsWith("WindowsForms10.BUTTON.app")) { int controlID = SUIWinAPIs.GetDlgCtrlID(ControlHandle); if (!controlList.ContainsKey(controlID)) { controlList.Add(controlID, controlWindow); } } } return(1); }
private int EnumControls(IntPtr ControlHandle, int lparam) { if (SUIWinAPIs.IsWindowVisible(ControlHandle)) { SUIWindow controlWindow = new SUIWindow(ControlHandle); //if (controlWindow.IsDialog) //{ // SUIWinAPIs.EnumChildWindows(ControlHandle, new EnumSMARTUIWindowsProc(EnumControls), 0); //} //else string WindowClassName = controlWindow.ClassName; if (WindowClassName.Equals("Button") || WindowClassName.Equals("Edit") || WindowClassName.Equals("ComboBox") || WindowClassName.Equals("Static") || WindowClassName.StartsWith("WindowsForms10.BUTTON.app")) { int controlID = SUIWinAPIs.GetDlgCtrlID(ControlHandle); if (!controlList.ContainsKey(controlID)) { controlList.Add(controlID, controlWindow); } } } return 1; }
public SUIAccessibility(SUIWindow accWin, AccType type) : this(accWin.WindowHandle, type) { }
//Sometimes, it needs a few seconds to initialize context menu and show it. //So I add a timeout parameter for this operation. public static SUIMsoCommandBarPopup MouseRightClick(SUIWindow window, string strWindowsText, int x, int y, int timeout) { SUIMouse.MouseRightClick(window, x, y); SUIWindow win = null; while (win == null && timeout > 0) { SUISleeper.Sleep(200); win = SUIWindow.DesktopWindow.FindChildWindow(WindowClass, strWindowsText); timeout--; } if (win == null) return null; return new SUIMsoCommandBarPopup(win); }
public SUIToolbar(SUIWindow win) : base(win) { }
public SUIPopupMenu(SUIWindow suiwin) : base(suiwin) { }
public SUIListView(SUIWindow win) : base(win) { }
public SUICheckBox(SUIWindow win) : base(win.WindowHandle) { }
public static Point GetPositionFromTextIndex(SUIWindow win, string text, int index) { return(GetPositionFromTextIndex(win.WindowHandle, text, index)); }
public static Point GetPositionFromTextIndex(SUIWindow win,string text, int index) { return GetPositionFromTextIndex(win.WindowHandle,text,index); }
public AtlTreeView(SUIWindow win) : this(win.WindowHandle) { }
public SUITextBox(SUIWindow sw) : base(sw) { }
public SUIAccessibility(SUIWindow accWin,AccType type):this(accWin.WindowHandle,type) { }
public SUIDotNetToolStrip(SUIWindow sui) : this(sui.WindowHandle) { }
public SUIComboBox(SUIWindow win) : base(win) { }
public SUIDotNetCheckBox(SUIWindow sui) : this(sui.WindowHandle) { }
public SUIMenu(SUIWindow dockedMainFrame) { this.dockedMainFrame = dockedMainFrame; }
public static SUIPopupMenu MouseRightClick(SUIWindow window, string strWindowsText, int x, int y) { //By default, I set timeout as 6 seconds! return(MouseRightClick(window, strWindowsText, x, y, 30)); }
public static Point GetPositionFromText(SUIWindow window,string text) { return GetPositionFromText(window.WindowHandle, text); }
public static Point GetPositionFromText(SUIWindow window, string text) { return(GetPositionFromText(window.WindowHandle, text)); }
public SUIListViewHeader(SUIWindow win) : base(win) { }
public SUITabControl(SUIWindow win) : this(win.WindowHandle) { }
public SUIDotNetPanel(SUIWindow sui) : this(sui.WindowHandle) { }
public static SUIMsoCommandBarPopup MouseRightClick(SUIWindow window, string strWindowsText, int x, int y) { //By default, I set timeout as 6 seconds! return MouseRightClick(window, strWindowsText, x, y, 30); }
public SUIDotNetContextMenuStrip(SUIWindow sui) : base(sui) { }
public SUIMsoCommandBarPopup(SUIWindow suiwin) : base(suiwin) { }
public SUIDotNetTextBox(SUIWindow sui) : this(sui.WindowHandle) { }
public SUIDotNetTabPage(SUIWindow sui) : this(sui.WindowHandle) { }
public SUIDotNetListBox(SUIWindow sui) : this(sui.WindowHandle) { }
public SUIRadioButton(SUIWindow win) : base(win.WindowHandle) { }