Beispiel #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         alissaWindows = WinApi.FindAllWindows("mod_Alissa");
            FoundWindow window        = null;

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

                window = FrmAlissaSelection.Selection;
            }

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

            return(true);
        }
Beispiel #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();
        }
        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();
        }
Beispiel #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);
        }
Beispiel #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;
        }