Beispiel #1
0
        public bool CloseMessageBox(ref string message, IntPtr handle)
        {
            try {
                WindowsTree wt = ListWindow(handle);
                for (int i = 0; i < wt.WindowCount; i++)
                {
                    WindowInfo info = wt.winfos[i];
                    //记录提示信息
                    if (info.title == "提示")
                    {
                        if ((sw.ElapsedMilliseconds > 20000) || (ptr_LastClosedHWND != info.hwnd)) //据上次关闭大于3S,或者要关闭的窗体是新窗体 (3S钟内不重复关闭一个窗体)
                        {
                            sw.Reset();
                            sw.Restart();
                            ptr_LastClosedHWND = info.hwnd;
                            AccessWin   aw       = new AccessWin();
                            WindowsTree wtsub    = aw.ListWindow(info.hwnd);
                            WindowsTree wtfilter = wtsub.FiltedbyClassName("Static");
                            for (int j = 0; j < wtfilter.WindowCount; j++)
                            {
                                WindowInfo infosub = wtfilter.winfos[j];
                                message = message + infosub.title + " ";
                                message = message.Trim();
                            }

                            //关闭窗口
                            WindowsTree wtfilter2 = wtsub.FiltedbyClassName("Button");
                            ClickButton(wtfilter2.winfos[0].hwnd);
                            ClickButton(wtfilter2.winfos[0].hwnd);
                            return(true);
                        }
                        else
                        {
                            int iii = 0;
                            iii++;
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                Console.Write(ee.StackTrace);
                return(false);
            }
            return(false);
        }
Beispiel #2
0
        public bool CloseSystemTreeBox(string title, ref string message, IntPtr handle)
        {
            try
            {
                WindowsTree wt = ListWindow(handle);
                for (int i = 0; i < wt.WindowCount; i++)
                {
                    WindowInfo info = wt.winfos[i];
                    //记录提示信息
                    if (info.title == title)
                    {
                        AccessWin   aw       = new AccessWin();
                        WindowsTree wtsub    = aw.ListWindow(info.hwnd);
                        WindowsTree wtfilter = wtsub.FiltedbyClassName("SysListView32");

                        DataTable dt = aw.GetListViewContent(wtfilter.winfos[0].hwnd);
                        for (int j = 0; j < dt.Rows.Count; j++)
                        {
                            for (int k = 0; k < dt.Columns.Count; k++)
                            {
                                message = message + dt.Rows[j][k].ToString() + "/";
                            }
                        }

                        //关闭窗口
                        WindowsTree wtfilter2 = wtsub.FiltedbyClassName("Button");
                        ClickButton(wtfilter2.winfos[0].hwnd);
                        ClickButton(wtfilter2.winfos[0].hwnd);
                        return(true);
                    }
                }
            }
            catch (Exception ee)
            {
                Console.Write(ee.StackTrace);
                return(false);
            }
            return(false);
        }
Beispiel #3
0
        public string FindText(IntPtr handle) //查找所有子控件包含的文本
        {
            //string message = "";
            //try
            //{
            //    WindowsTree wt = ListWindow(handle);
            //    for (int i = 0; i < wt.WindowCount; i++)
            //    {
            //        //记录提示信息
            //        WindowsTree wtfilter = wt.FiltedbyClassName("Static");
            //        for (int j = 0; j < wtfilter.WindowCount; j++)
            //        {
            //            WindowInfo infosub = wtfilter.winfos[j];
            //            message = message + infosub.title + " ";
            //            message = message.Trim();
            //        }
            //    }
            //}
            StringBuilder message   = new StringBuilder("");
            string        s_message = "";

            try
            {
                WindowsTree wt = ListWindow(handle);
                //记录提示信息
                WindowsTree wtfilter = wt.FiltedbyClassName("Static");
                if (wtfilter == null)
                {
                    return("");
                }
                for (int j = 0; j < wtfilter.WindowCount; j++)
                {
                    WindowInfo infosub = wtfilter.winfos[j];
                    message.Append(infosub.title + " ");
                    s_message = message.ToString().Trim();;
                }
            }
            catch (Exception ee)
            {
                Console.Write(ee.StackTrace);
                return("");
            }
            return(s_message);
        }