Describes a window found with the FindAllWindows function.
Esempio n. 1
0
        /// <summary>
        /// Tries to find a valid packet provider, asks the user to select one
        /// if there are multiple windows.
        /// </summary>
        /// <param name="selectSingle">If true a single valid candidate will be selected without prompt.</param>
        /// <returns></returns>
        private bool SelectPacketProvider(bool selectSingle)
        {
            var         windows = WinApi.FindAllWindows("mod_Tossa");
            FoundWindow window  = null;

            if (windows.Count == 0)
            {
                MessageBox.Show("No packet provider found.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            else if (selectSingle && windows.Count == 1)
            {
                window = windows[0];
            }
            else
            {
                var form = new FrmProviderSelection(windows, LblPacketProvider.Text);
                if (form.ShowDialog() == DialogResult.Cancel)
                {
                    return(false);
                }

                window = FrmProviderSelection.Selection;
            }

            providerHWnd           = window.HWnd;
            LblPacketProvider.Text = window.ClassName;

            return(true);
        }
Esempio n. 2
0
        private void BtnConnect_Click(object sender, EventArgs e)
        {
            if (CboWindows.SelectedItem == null)
            {
                MessageBox.Show("Please select a packet provider.", Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            Selection = (FoundWindow)CboWindows.SelectedItem;
            DialogResult = DialogResult.OK;

            Close();
        }
Esempio n. 3
0
        private void BtnConnect_Click(object sender, EventArgs e)
        {
            if (CboWindows.SelectedItem == null)
            {
                MessageBox.Show("Please select a packet provider.", Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            Selection    = (FoundWindow)CboWindows.SelectedItem;
            DialogResult = DialogResult.OK;

            Close();
        }
Esempio n. 4
0
        /// <summary>
        /// Custom: Returns list of all windows with given name,
        /// utilizing FindWindowEx and GetClassName.
        /// </summary>
        /// <returns></returns>
        public static IList <FoundWindow> FindAllWindows(string windowName)
        {
            var result = new List <FoundWindow>();

            var hWnd = IntPtr.Zero;

            do
            {
                if ((hWnd = FindWindowEx(IntPtr.Zero, hWnd, null, windowName)) != IntPtr.Zero)
                {
                    var window = new FoundWindow();
                    window.HWnd       = hWnd;
                    window.WindowName = windowName;

                    var className = new StringBuilder(255);
                    GetClassName(hWnd, className, className.Capacity);
                    window.ClassName = className.ToString();

                    result.Add(window);
                }
            }while (hWnd != IntPtr.Zero);

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// Custom: Returns list of all windows with given name,
        /// utilizing FindWindowEx and GetClassName.
        /// </summary>
        /// <returns></returns>
        public static IList<FoundWindow> FindAllWindows(string windowName)
        {
            var result = new List<FoundWindow>();

            var hWnd = IntPtr.Zero;
            do
            {
                if ((hWnd = FindWindowEx(IntPtr.Zero, hWnd, null, windowName)) != IntPtr.Zero)
                {
                    var window = new FoundWindow();
                    window.HWnd = hWnd;
                    window.WindowName = windowName;

                    var className = new StringBuilder(255);
                    GetClassName(hWnd, className, className.Capacity);
                    window.ClassName = className.ToString();

                    result.Add(window);
                }
            }
            while (hWnd != IntPtr.Zero);

            return result;
        }