void IWin32WindowsNativeMethods.EnumChildWindows(
            IntPtr parentWindowHandle, EnumChildWindowsProc enumWindowsCallback, WindowFinderEnumChildWindowsProcContext context)
        {
            ArgumentUtility.CheckNotNull("enumWindowsCallback", enumWindowsCallback);
            ArgumentUtility.CheckNotNull("context", context);

            EnumChildWindows(parentWindowHandle, enumWindowsCallback, context);
        }
Exemplo n.º 2
0
        public static void StartListening(IntPtr hwndParent)
        {
            EnumChildWindowsProc myEnumChild = new EnumChildWindowsProc(EumWinChiPro);

            try
            {
                EnumChildWindows(hwndParent, myEnumChild, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Exemplo n.º 3
0
        public static extern long GetWindowRect(IntPtr hWnd, out RECT lpRect);//System.Windows.Rectangle does not work properly !

        public List <IntPtr> GetChildWindows(IntPtr parent)
        {
            List <IntPtr> result     = new List <IntPtr>();
            GCHandle      listHandle = GCHandle.Alloc(result);

            try
            {
                EnumChildWindowsProc childProc = new EnumChildWindowsProc(EnumChildWindow);
                EnumChildWindows(parent, childProc, GCHandle.ToIntPtr(listHandle));
            }
            finally
            {
                if (listHandle.IsAllocated)
                {
                    listHandle.Free();
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        private void SearchWindow()
        {
            string lpszParentClass  = "TMain";                            //整个窗口的类名
            string lpszParentWindow = "Member's Information and Result."; //窗口标题
            IntPtr hWndParent       = new IntPtr(0);
            IntPtr EdithWnd         = new IntPtr(0);

            //查到窗体,得到整个窗体
            hWndParent = FindWindow(lpszParentClass, lpszParentWindow);

            //实例化
            EnumChildWindowsProc myEnumChild = new EnumChildWindowsProc(EumWinChiPro);

            try
            {
                //遍历子控件
                EnumChildWindows(hWndParent, myEnumChild, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.Source + "\r\n\r\n" + ex.StackTrace.ToString());
            }
        }
Exemplo n.º 5
0
 public static extern int EnumChildWindows(IntPtr hWndParent, EnumChildWindowsProc lpfn, int lParam);
Exemplo n.º 6
0
        static IntPtr reconnection = IntPtr.Zero;//重新连接按钮句柄

        ///<summary>
        /// ADSL拨号
        ///</summary>
        ///<param name="adslUserName">adsl用户名</param>
        ///<param name="adslPasswd">adsl密码</param>
        ///<returns></returns>
        public static bool DoAdsl(string adslUserName, string adslPasswd)
        {
            string username = adslUserName;
            string passwd   = adslPasswd;

            //下面的这些参数都可以用Spy++查到
            string lpszParentClass  = "#32770";  //整个窗口的类名
            string lpszParentWindow = "连接 宽带连接"; //窗口标题
            string lpszClass        = "Edit";    //需要查找的子窗口的类名,也就是输入框
            string lpszClass_Submit = "Button";  //需要查找的Button的类名
            string lpszName_Submit  = "连接(&C)";  //需要查找的Button的标题

            IntPtr parentHWND = new IntPtr(0);

            //查到窗体,得到整个主窗口句柄
            while (true)
            {
                parentHWND = FindWindow(lpszParentClass, lpszParentWindow);
                if (parentHWND != IntPtr.Zero)
                {
                    break;
                }
                Thread.Sleep(100);
            }

            if (!parentHWND.Equals(IntPtr.Zero))
            {
                IntPtr childHWND = new IntPtr(0);
                childHWND = FindWindowEx(parentHWND, childHWND, lpszClass, string.Empty);           //得到User Name这个子窗体
                SendMessage(childHWND, WM_SETTEXT, IntPtr.Zero, username);                          //调用SendMessage方法设置其内容
                childHWND = FindWindowEx(parentHWND, childHWND, lpszClass, string.Empty);           //得到Password这个子窗体
                SendMessage(childHWND, WM_SETTEXT, IntPtr.Zero, passwd);
                childHWND = FindWindowEx(parentHWND, childHWND, lpszClass_Submit, lpszName_Submit); //得到Button这个子窗体
                SendMessage(childHWND, WM_CLICK, IntPtr.Zero, "0");                                 //触发Click事件

                Thread.Sleep(500);
                while (true)
                {
                    if (FindWindow("#32770", "正在连接 宽带连接...") == IntPtr.Zero)//表示连接成功
                    {
                        break;
                    }
                    IntPtr errorParent = FindWindow("#32770", "连接到 宽带连接 时出错");
                    if (errorParent != IntPtr.Zero)
                    {
                        //获取'重拨(&R)'按钮句柄
                        EnumChildWindowsProc myEnumChild = new EnumChildWindowsProc(EumWinChiPro);
                        try
                        {
                            EnumChildWindows(errorParent, myEnumChild, 0);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message + "\r\n " + ex.Source + "\r\n\r\n " + ex.StackTrace.ToString());
                        }
                        if (reconnection != IntPtr.Zero)
                        {
                            SendMessage(reconnection, WM_CLICK, (IntPtr)0, "0");
                        }
                    }
                    Thread.Sleep(1000);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 7
0
 private static extern bool EnumChildWindows(IntPtr hWndParent, EnumChildWindowsProc lpEnumFunc, int lParam);
Exemplo n.º 8
0
 private static extern bool EnumChildWindows(IntPtr hWnd, EnumChildWindowsProc lpEnumFunc, IntPtr lParam);
Exemplo n.º 9
0
 public static extern bool EnumThreadWindows(int threadId, EnumChildWindowsProc lpEnumFunc, IntPtr lParam);
Exemplo n.º 10
0
 public static extern bool EnumChildWindows(IntPtr hWndParent, EnumChildWindowsProc lpEnumFunc, IntPtr lParam);
Exemplo n.º 11
0
 public static extern int EnumChildWindows(
     int hWndParent,
     EnumChildWindowsProc lpEnumFunc,
     int lParam
 );
 private static extern bool EnumChildWindows(IntPtr hwndParent, EnumChildWindowsProc lpEnumFunc, WindowFinderEnumChildWindowsProcContext data);
 public static extern bool EnumThreadWindows(int threadId, EnumChildWindowsProc lpEnumFunc, IntPtr lParam);
 public static extern bool EnumChildWindows(IntPtr hWndParent, EnumChildWindowsProc lpEnumFunc, IntPtr lParam);
Exemplo n.º 15
0
        private void SearchWindow()
        {
            string lpszParentClass = "TMain"; //整个窗口的类名
            string lpszParentWindow = "Member's Information and Result."; //窗口标题
            IntPtr hWndParent = new IntPtr(0);
            IntPtr EdithWnd = new IntPtr(0);

            //查到窗体,得到整个窗体
            hWndParent = FindWindow(lpszParentClass, lpszParentWindow);

            //实例化
            EnumChildWindowsProc myEnumChild = new EnumChildWindowsProc(EumWinChiPro);
            try
            {
                //遍历子控件
                EnumChildWindows(hWndParent, myEnumChild, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.Source + "\r\n\r\n" + ex.StackTrace.ToString());
            }
        }
Exemplo n.º 16
0
 public static extern long EnumChildWindows(IntPtr hWndParent, EnumChildWindowsProc lpEnumFunc, long lParam);