Пример #1
0
        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);
        }
Пример #2
0
        // 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;
        }
Пример #3
0
        // 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);
        }
Пример #4
0
        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;
        }
Пример #5
0
 public static SUIHtmlDocument GetSUIHtmlDocumentFromWindow(SUIWindow window)
 {
     IHTMLDocument2 doc = GetIEDocumentFromWindow(window);
     SUIHtmlDocument SUIDoc = new SUIHtmlDocument(doc);
     SUIDoc.InternetServer = window;
     return SUIDoc;
 }
Пример #6
0
 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);
 }
Пример #7
0
        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);
        }
Пример #8
0
        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;
        }
Пример #9
0
        public static SUIHtmlDocument GetSUIHtmlDocumentFromWindow(SUIWindow window)
        {
            IHTMLDocument2  doc    = GetIEDocumentFromWindow(window);
            SUIHtmlDocument SUIDoc = new SUIHtmlDocument(doc);

            SUIDoc.InternetServer = window;
            return(SUIDoc);
        }
Пример #10
0
        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);
        }
Пример #11
0
 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);
 }
Пример #12
0
 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);
 }
Пример #13
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;
 }
Пример #14
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);
        }
Пример #15
0
        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);
        }
Пример #16
0
 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;
 }
Пример #17
0
        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;
        }
Пример #18
0
        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);
        }
Пример #19
0
        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;

        }
Пример #20
0
        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);
        }
Пример #21
0
        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);
        }
Пример #22
0
        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);
        }
Пример #23
0
        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);
        }
Пример #24
0
        //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));
        }
Пример #25
0
        //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));
        }
Пример #26
0
        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);
        }
Пример #27
0
        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));
        }
Пример #28
0
 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);
 }
Пример #29
0
 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;
 }
Пример #30
0
 public SUIAccessibility(SUIWindow accWin, AccType type) : this(accWin.WindowHandle, type)
 {
 }
Пример #31
0
        //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);
        }
Пример #32
0
 public SUIToolbar(SUIWindow win)
     : base(win)
 { }
Пример #33
0
 public SUIPopupMenu(SUIWindow suiwin)
     : base(suiwin)
 {
 }
Пример #34
0
 public SUIListView(SUIWindow win)
     : base(win)
 { }
Пример #35
0
 public SUICheckBox(SUIWindow win)
     : base(win.WindowHandle)
 { }
Пример #36
0
 public static Point GetPositionFromTextIndex(SUIWindow win, string text, int index)
 {
     return(GetPositionFromTextIndex(win.WindowHandle, text, index));
 }
Пример #37
0
 public static Point GetPositionFromTextIndex(SUIWindow win,string text, int index)
 {
     return GetPositionFromTextIndex(win.WindowHandle,text,index);
 }
Пример #38
0
 public AtlTreeView(SUIWindow win)
     : this(win.WindowHandle)
 {
 }
Пример #39
0
 public SUITextBox(SUIWindow sw)
     : base(sw)
 {
 }
Пример #40
0
 public SUIAccessibility(SUIWindow accWin,AccType type):this(accWin.WindowHandle,type)
 { }
Пример #41
0
 public SUIDotNetToolStrip(SUIWindow sui)
     : this(sui.WindowHandle)
 {
 }
Пример #42
0
 public SUIComboBox(SUIWindow win)
     : base(win)
 {
 }
Пример #43
0
 public SUIDotNetCheckBox(SUIWindow sui)
     : this(sui.WindowHandle)
 {
 }
Пример #44
0
 public SUIMenu(SUIWindow dockedMainFrame)
 {
     this.dockedMainFrame = dockedMainFrame;
 }
Пример #45
0
 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));
 }
Пример #46
0
 public static Point GetPositionFromText(SUIWindow window,string text)
 {
     return GetPositionFromText(window.WindowHandle, text);
 }
Пример #47
0
 public static Point GetPositionFromText(SUIWindow window, string text)
 {
     return(GetPositionFromText(window.WindowHandle, text));
 }
Пример #48
0
 public SUIListView(SUIWindow win)
     : base(win)
 {
 }
Пример #49
0
 public SUIListViewHeader(SUIWindow win)
     : base(win)
 {
 }
Пример #50
0
 public SUITabControl(SUIWindow win)
     : this(win.WindowHandle)
 {
 }
Пример #51
0
 public SUIDotNetPanel(SUIWindow sui)
     : this(sui.WindowHandle)
 {
 }
Пример #52
0
 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)
 {
 }
Пример #54
0
 public SUIMsoCommandBarPopup(SUIWindow suiwin)
     : base(suiwin)
 {
     
 }
Пример #55
0
 public SUIDotNetTextBox(SUIWindow sui)
     : this(sui.WindowHandle)
 {
     
 }
Пример #56
0
 public SUITextBox(SUIWindow sw)
     : base(sw)
 { }
Пример #57
0
 public SUIDotNetTabPage(SUIWindow sui)
     : this(sui.WindowHandle)
 {
 }
Пример #58
0
 public SUIDotNetListBox(SUIWindow sui)
     : this(sui.WindowHandle)
 {
 }
Пример #59
0
 public SUIRadioButton(SUIWindow win)
     : base(win.WindowHandle)
 { }
Пример #60
0
 public SUIDotNetContextMenuStrip(SUIWindow sui)
     : base(sui)
 {
 }