Exemple #1
0
        public static Dictionary <string, string> GetInfos(params string[] keys)
        {
            IntPtr tvHwnd = WindowsApi.FindWindow(null, "TeamViewer");
            var    sets   = new HashSet <string>();

            sets.UnionWith(keys);
            return(CheckPtrInfo(tvHwnd, sets));
        }
        public static RemoveController GetUser()
        {
            RemoveController user   = new RemoveController();
            IntPtr           tvHwnd = WindowsApi.FindWindow(null, "TeamViewer");

            if (tvHwnd != IntPtr.Zero)
            {
                IntPtr winParentPtr = WindowsApi.GetWindow(tvHwnd, GetWindowCmd.GW_CHILD);
                while (winParentPtr != IntPtr.Zero)
                {
                    IntPtr winSubPtr = WindowsApi.GetWindow(winParentPtr, GetWindowCmd.GW_CHILD);
                    while (winSubPtr != IntPtr.Zero)
                    {
                        StringBuilder controlName = new StringBuilder(512);
                        //获取控件类型
                        WindowsApi.GetClassName(winSubPtr, controlName, controlName.Capacity);

                        if (controlName.ToString() == "Edit")
                        {
                            StringBuilder winMessage = new StringBuilder(512);
                            //获取控件内容 0xD
                            WindowsApi.SendMessage(winSubPtr, 0xD, (IntPtr)winMessage.Capacity, winMessage);
                            string message = winMessage.ToString();
                            if (userReg.IsMatch(message))
                            {
                                user.Username = message;
                                user._count  += 1;
                            }
                            else if (user.Password != string.Empty)
                            {
                                user.Holder  = message;
                                user._count += 1;
                            }
                            else
                            {
                                user.Password = message;
                                user._count  += 1;
                            }
                            if (user._count == 3)
                            {
                                return(user);
                            }
                        }

                        //获取当前子窗口中的下一个控件
                        winSubPtr = WindowsApi.GetWindow(winSubPtr, GetWindowCmd.GW_HWNDNEXT);
                    }
                    //获取当前子窗口中的下一个控件
                    winParentPtr = WindowsApi.GetWindow(winParentPtr, GetWindowCmd.GW_HWNDNEXT);
                }
            }
            return(user);
        }
        public static Dictionary <string, string> GetInfos(params string[] keys)
        {
            IntPtr tvHwnd = WindowsApi.FindWindow(null, "TeamViewer");

            return(CheckPtrInfo(tvHwnd, ImmutableHashSet.CreateRange(keys)));
        }