示例#1
0
        private void OnMessageHook(object sender, MessageHookEventArgs e)
        {
            const int WM_LBUTTONDOWN   = 0x0201;
            const int WM_RBUTTONDOWN   = 0x0204;
            const int WM_MOUSEWHEEL    = 0x020A;
            const int WM_MBUTTONDOWN   = 0x0207;
            const int WM_NCLBUTTONDOWN = 0x00A1;
            const int WM_NCMBUTTONDOWN = 0x00A7;
            const int WM_NCRBUTTONDOWN = 0x00A4;

            if (e.Msg == WM_LBUTTONDOWN ||
                e.Msg == WM_RBUTTONDOWN ||
                e.Msg == WM_MBUTTONDOWN ||
                e.Msg == WM_MOUSEWHEEL ||
                e.Msg == WM_NCLBUTTONDOWN ||
                e.Msg == WM_NCMBUTTONDOWN ||
                e.Msg == WM_NCRBUTTONDOWN)
            {
                if (!AssociatedObject.IsMouseDirectlyOver)
                {
                    AssociatedObject.IsOpen = false;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Fires when a SHOWWINDOW message is received from the table
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void wh_OnMessageHook(object sender, MessageHookEventArgs e)
        {
            switch (e.msg)
            {
            // A window has been hidden / visible
            case StandardMessages.WM_SHOWWINDOW:
                string txt = Win32.GetText((int)e.hwnd).ToLower();

                if (txt.Length == 0)
                {
                    return;
                }

                Log.Write("WinHooker: WM_SHOWWINDOW - '" + txt + "', visibility: " + e.wp);

                ChildWindow child = new ChildWindow((int)e.hwnd);

                if ((txt.StartsWith("raise") || txt.StartsWith("bet") || txt.StartsWith("all") || txt.StartsWith("fold") || txt.StartsWith("wait") || txt.StartsWith("call") || txt.StartsWith("check") || txt.StartsWith("post") || txt.StartsWith("sit out")) && !txt.Contains("respond"))
                {
                    Log.Write("Window is action text");
                    if (child.SizeRatio < 4)
                    {
                        Log.Write("Window has correct size ratio, wp is: " + e.wp + ", needsAction is: " + needsAction);
                        if (Convert.ToBoolean(e.wp) && !needsAction)
                        {
                            Log.Write("Needs action now");

                            // Update children
                            UpdateChildren();

                            // We need action now, we didn't before
                            needsAction = true;

                            // If it's a tourney, check the blind level
                            if (GameForm == TableFactory.GameForm.SNG)
                            {
                                // Get blind level
                                int newBlindLevel = getBlindLevel();

                                // Save the blind level and destroy the border form
                                if (blindLevel != newBlindLevel)
                                {
                                    if (borderForm != null && !borderForm.Visible)
                                    {
                                        borderForm.Dispose();
                                        borderForm = null;
                                    }

                                    blindLevel = newBlindLevel;
                                }
                            }

                            // Fire event
                            requiresAction();

                            // Start timer
                            watch.Reset();
                            watch.Start();

                            // Update last action date
                            lastRequiredAction = DateTime.Now;
                        }
                        else if (needsAction && !Convert.ToBoolean(e.wp))
                        {
                            Log.Write("No longer needs action");

                            // We don't need action any more
                            needsAction = false;

                            // Fire event
                            noLongerRequiresAction();

                            // Stop timer
                            watch.Stop();
                            cumulativeResponseTime += watch.ElapsedMilliseconds;
                            actionCount++;

                            // Update last action date
                            lastRequiredAction = DateTime.Now;
                        }

                        actionButtonsVisible = Convert.ToBoolean(e.wp);

                        // Check if it's wait for bb button
                        if (txt == "wait for bb" && Settings.AutoWaitForBB && Convert.ToBoolean(e.wp))
                        {
                            Log.Write("Wait for BB detected, autowait enabled, clicking button");

                            Win32.ClickButton((int)e.hwnd);

                            if (Settings.AutoClickAutoPostBlind)
                            {
                                Log.Write("We've clicked wait for bb button, now click auto post blind");

                                CheckAutoPostBlind();
                            }

                            return;
                        }

                        // Check if it's post sb/bb button
                        if ((txt.StartsWith("post bb") || txt.StartsWith("post sb")) && Settings.AutoPostBlind && Convert.ToBoolean(e.wp))
                        {
                            Log.Write("Post sb/bb detected");

                            if (!Settings.AutoWaitForBB)
                            {
                                Log.Write("We're not waiting for bb, clicking post button");

                                Win32.ClickButton((int)e.hwnd);

                                if (Settings.AutoClickAutoPostBlind)
                                {
                                    Log.Write("We've posted a blind, and we're auto clicking auto post blind");

                                    CheckAutoPostBlind();
                                }
                            }
                            else
                            {
                                Log.Write("We're waiting for bb, launching delayed click of wait for sb button");

                                System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();

                                t.Interval = 80;
                                t.Tag      = e.hwnd.ToString();

                                t.Tick += new EventHandler(delegate(object tSender, EventArgs eArgs)
                                {
                                    int hwnd = Convert.ToInt32(((System.Windows.Forms.Timer)tSender).Tag);

                                    Log.Write("Delayed post blind timer tick");

                                    if (Win32.IsWindowVisible(hwnd))
                                    {
                                        if (Win32.GetText(hwnd).ToLower().StartsWith("post "))
                                        {
                                            Log.Write("Post blind button still available, clicking");

                                            Win32.ClickButton(hwnd);

                                            if (Settings.AutoClickAutoPostBlind)
                                            {
                                                Log.Write("We've posted a blind, and we're auto clicking auto post blind");

                                                CheckAutoPostBlind();
                                            }
                                        }
                                    }

                                    t.Enabled = false;
                                });

                                t.Enabled = true;
                            }
                        }
                    }
                }
                else if (txt.StartsWith("i am back") && child.SizeRatio < 4)
                {
                    Log.Write("Window is sitting out text, wp is: " + e.wp + ", IsSittingOut is: " + IsSittingOut);

                    if (Convert.ToBoolean(e.wp) && !IsSittingOut)
                    {
                        Log.Write("Sitting out now");

                        // We're sitting out now, we didn't before
                        IsSittingOut = true;

                        sittingOut();
                    }
                    else if (IsSittingOut && !Convert.ToBoolean(e.wp))
                    {
                        Log.Write("No longer sitting out");

                        // We're not sitting out any longer
                        IsSittingOut = false;
                    }
                }
                break;
            }
        }
        /// <summary>
        /// Fires when a SHOWWINDOW message is received from the table
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void wh_OnMessageHook(object sender, MessageHookEventArgs e)
        {
            switch (e.msg)
            {
                // A window has been hidden / visible
                case StandardMessages.WM_SHOWWINDOW:
                    string txt = Win32.GetText((int)e.hwnd).ToLower();

                    if (txt.Length == 0)
                        return;

                    Log.Write("WinHooker: WM_SHOWWINDOW - '" + txt + "', visibility: " + e.wp);

                    ChildWindow child = new ChildWindow((int)e.hwnd);

                    if ((txt.StartsWith("raise") || txt.StartsWith("bet") || txt.StartsWith("all") || txt.StartsWith("fold") || txt.StartsWith("wait") || txt.StartsWith("call") || txt.StartsWith("check") || txt.StartsWith("post") || txt.StartsWith("sit out")) && !txt.Contains("respond"))
                    {
                        Log.Write("Window is action text");
                        if (child.SizeRatio < 4)
                        {
                            Log.Write("Window has correct size ratio, wp is: " + e.wp + ", needsAction is: " + needsAction);
                            if (Convert.ToBoolean(e.wp) && !needsAction)
                            {
                                Log.Write("Needs action now");

                                // Update children
                                UpdateChildren();

                                // We need action now, we didn't before
                                needsAction = true;

                                // If it's a tourney, check the blind level
                                if (GameForm == TableFactory.GameForm.SNG)
                                {
                                    // Get blind level
                                    int newBlindLevel = getBlindLevel();

                                    // Save the blind level and destroy the border form
                                    if (blindLevel != newBlindLevel)
                                    {
                                        if (borderForm != null && !borderForm.Visible)
                                        {
                                            borderForm.Dispose();
                                            borderForm = null;
                                        }

                                        blindLevel = newBlindLevel;
                                    }
                                }

                                // Fire event
                                requiresAction();

                                // Start timer
                                watch.Reset();
                                watch.Start();

                                // Update last action date
                                lastRequiredAction = DateTime.Now;
                            }
                            else if (needsAction && !Convert.ToBoolean(e.wp))
                            {
                                Log.Write("No longer needs action");

                                // We don't need action any more
                                needsAction = false;

                                // Fire event
                                noLongerRequiresAction();

                                // Stop timer
                                watch.Stop();
                                cumulativeResponseTime += watch.ElapsedMilliseconds;
                                actionCount++;

                                // Update last action date
                                lastRequiredAction = DateTime.Now;
                            }

                            actionButtonsVisible = Convert.ToBoolean(e.wp);

                            // Check if it's wait for bb button
                            if (txt == "wait for bb" && Settings.AutoWaitForBB && Convert.ToBoolean(e.wp))
                            {
                                Log.Write("Wait for BB detected, autowait enabled, clicking button");

                                Win32.ClickButton((int)e.hwnd);

                                if (Settings.AutoClickAutoPostBlind)
                                {
                                    Log.Write("We've clicked wait for bb button, now click auto post blind");

                                    CheckAutoPostBlind();
                                }

                                return;
                            }

                            // Check if it's post sb/bb button
                            if ((txt.StartsWith("post bb") || txt.StartsWith("post sb")) && Settings.AutoPostBlind && Convert.ToBoolean(e.wp))
                            {
                                Log.Write("Post sb/bb detected");

                                if (!Settings.AutoWaitForBB)
                                {
                                    Log.Write("We're not waiting for bb, clicking post button");

                                    Win32.ClickButton((int)e.hwnd);

                                    if (Settings.AutoClickAutoPostBlind)
                                    {
                                        Log.Write("We've posted a blind, and we're auto clicking auto post blind");

                                        CheckAutoPostBlind();
                                    }
                                }
                                else
                                {
                                    Log.Write("We're waiting for bb, launching delayed click of wait for sb button");

                                    System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();

                                    t.Interval = 80;
                                    t.Tag = e.hwnd.ToString();

                                    t.Tick += new EventHandler(delegate(object tSender, EventArgs eArgs)
                                    {
                                        int hwnd = Convert.ToInt32(((System.Windows.Forms.Timer)tSender).Tag);

                                        Log.Write("Delayed post blind timer tick");

                                        if (Win32.IsWindowVisible(hwnd))
                                            if (Win32.GetText(hwnd).ToLower().StartsWith("post "))
                                            {
                                                Log.Write("Post blind button still available, clicking");

                                                Win32.ClickButton(hwnd);

                                                if (Settings.AutoClickAutoPostBlind)
                                                {
                                                    Log.Write("We've posted a blind, and we're auto clicking auto post blind");

                                                    CheckAutoPostBlind();
                                                }
                                            }

                                        t.Enabled = false;

                                    });

                                    t.Enabled = true;
                                }
                            }
                        }
                    }
                    else if (txt.StartsWith("i am back") && child.SizeRatio < 4)
                    {
                        Log.Write("Window is sitting out text, wp is: " + e.wp + ", IsSittingOut is: " + IsSittingOut);

                        if (Convert.ToBoolean(e.wp) && !IsSittingOut)
                        {
                            Log.Write("Sitting out now");

                            // We're sitting out now, we didn't before
                            IsSittingOut = true;

                            sittingOut();
                        }
                        else if (IsSittingOut && !Convert.ToBoolean(e.wp))
                        {
                            Log.Write("No longer sitting out");

                            // We're not sitting out any longer
                            IsSittingOut = false;
                        }
                    }
                    break;
            }
        }
        void wh_OnMessageHook(object sender, MessageHookEventArgs e)
        {
            switch (e.msg)
            {
                // A window has been hidden / visible
                case StandardMessages.WM_SHOWWINDOW:
                    string txt = Win32.GetText((int)e.hwnd).ToLower();

                    if (txt.Length == 0)
                        return;

                    ChildWindow child = new ChildWindow((int)e.hwnd);

                    if ((txt.StartsWith("raise") || txt.StartsWith("bet") || txt.StartsWith("all") || txt.StartsWith("fold") || txt.StartsWith("wait") || txt.StartsWith("call") || txt.StartsWith("check") || txt.StartsWith("post") || txt.StartsWith("sit out")) && !txt.Contains("respond"))
                    {
                        if (child.SizeRatio < 4)
                        {
                            if (Convert.ToBoolean(e.wp) && !needsAction)
                            {
                                // Requires action
                                needsAction = true;
                                OnRequiresAction();
                                ForceRedraw();
                            }
                            else if (needsAction && !Convert.ToBoolean(e.wp))
                            {
                                // No longer requires action
                                needsAction = false;
                                OnNoLongerRequiresAction();
                            }
                        }
                    }
                    else if (txt.StartsWith("i am back") && child.SizeRatio < 4)
                    {
                        if (Convert.ToBoolean(e.wp) && !isSittingOut)
                        {
                            // Sitting out
                            isSittingOut = true;
                            OnSittingOut();
                        }
                        else if (isSittingOut && !Convert.ToBoolean(e.wp))
                        {
                            // Sitting in
                            isSittingOut = false;
                            OnSittingIn();
                        }
                    }
                    else if (txt.StartsWith("Deal Me Out"))
                    {
                        if (Convert.ToBoolean(e.wp) && !isSeated)
                        {
                            // Seated
                            isSeated = true;
                            OnSeated();
                        }
                        else if (isSeated && !Convert.ToBoolean(e.wp))
                        {
                            // Unseated
                            isSeated = false;
                            OnUnSeated();
                        }
                    }
                    break;
            }
        }
        void wh_OnMessageHook(object sender, MessageHookEventArgs e)
        {
            switch (e.msg)
            {
            // A window has been hidden / visible
            case StandardMessages.WM_SHOWWINDOW:
                string txt = Win32.GetText((int)e.hwnd).ToLower();

                if (txt.Length == 0)
                {
                    return;
                }

                ChildWindow child = new ChildWindow((int)e.hwnd);

                if ((txt.StartsWith("raise") || txt.StartsWith("bet") || txt.StartsWith("all") || txt.StartsWith("fold") || txt.StartsWith("wait") || txt.StartsWith("call") || txt.StartsWith("check") || txt.StartsWith("post") || txt.StartsWith("sit out")) && !txt.Contains("respond"))
                {
                    if (child.SizeRatio < 4)
                    {
                        if (Convert.ToBoolean(e.wp) && !needsAction)
                        {
                            // Requires action
                            needsAction = true;
                            OnRequiresAction();
                            ForceRedraw();
                        }
                        else if (needsAction && !Convert.ToBoolean(e.wp))
                        {
                            // No longer requires action
                            needsAction = false;
                            OnNoLongerRequiresAction();
                        }
                    }
                }
                else if (txt.StartsWith("i am back") && child.SizeRatio < 4)
                {
                    if (Convert.ToBoolean(e.wp) && !isSittingOut)
                    {
                        // Sitting out
                        isSittingOut = true;
                        OnSittingOut();
                    }
                    else if (isSittingOut && !Convert.ToBoolean(e.wp))
                    {
                        // Sitting in
                        isSittingOut = false;
                        OnSittingIn();
                    }
                }
                else if (txt.StartsWith("Deal Me Out"))
                {
                    if (Convert.ToBoolean(e.wp) && !isSeated)
                    {
                        // Seated
                        isSeated = true;
                        OnSeated();
                    }
                    else if (isSeated && !Convert.ToBoolean(e.wp))
                    {
                        // Unseated
                        isSeated = false;
                        OnUnSeated();
                    }
                }
                break;
            }
        }
示例#6
0
        /// <summary>
        /// Fires when a SHOWWINDOW message is received from the table
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void wh_OnMessageHook(object sender, MessageHookEventArgs e)
        {
            switch (e.msg)
            {
                // A window has been hidden / visible
                case StandardMessages.WM_SHOWWINDOW:
                    int buttonCode = Win32.GetControlIDFromHwnd((int)e.hwnd);

                    Log.Write("WinHooker: WM_SHOWWINDOW - '" + buttonCode + "', visibility: " + e.wp);

                    ChildWindow child = new ChildWindow((int)e.hwnd);

                    if (buttonCode == 1031 || buttonCode == 1032 || buttonCode == 1033)
                    {
                        Log.Write("Window has correct size ratio, wp is: " + e.wp + ", needsAction is: " + needsAction);
                        if (Convert.ToBoolean(e.wp) && !needsAction)
                        {
                            Log.Write("Needs action now");

                            // Update children
                            UpdateChildren();

                            // We need action now, we didn't before
                            needsAction = true;

                            // Fire event
                            requiresAction();

                            // Start timer
                            watch.Reset();
                            watch.Start();

                            // Update last action date
                            lastRequiredAction = DateTime.Now;
                        }
                        else if (needsAction && !Convert.ToBoolean(e.wp))
                        {
                            Log.Write("No longer needs action");

                            // We don't need action any more
                            needsAction = false;

                            // Fire event
                            noLongerRequiresAction();

                            // Stop timer
                            watch.Stop();
                            cumulativeResponseTime += watch.ElapsedMilliseconds;
                            actionCount++;

                            // Update last action date
                            lastRequiredAction = DateTime.Now;
                        }

                        actionButtonsVisible = Convert.ToBoolean(e.wp);
                    }
                    else if (buttonCode == 1035) // "DEAL ME IN"
                    {
                        Log.Write("Window is sitting out text, wp is: " + e.wp + ", IsSittingOut is: " + IsSittingOut);

                        if (Convert.ToBoolean(e.wp) && !IsSittingOut)
                        {
                            Log.Write("Sitting out now");

                            // We're sitting out now, we didn't before
                            IsSittingOut = true;

                            sittingOut();
                        }
                        else if (IsSittingOut && !Convert.ToBoolean(e.wp))
                        {
                            Log.Write("No longer sitting out");

                            // We're not sitting out any longer
                            IsSittingOut = false;
                        }
                    }
                    break;
            }
        }
示例#7
0
        /// <summary>
        /// Fires when a SHOWWINDOW message is received from the table
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void wh_OnMessageHook(object sender, MessageHookEventArgs e)
        {
            switch (e.msg)
            {
            // A window has been hidden / visible
            case StandardMessages.WM_SHOWWINDOW:
                int buttonCode = Win32.GetControlIDFromHwnd((int)e.hwnd);

                Log.Write("WinHooker: WM_SHOWWINDOW - '" + buttonCode + "', visibility: " + e.wp);

                ChildWindow child = new ChildWindow((int)e.hwnd);

                if (buttonCode == 1031 || buttonCode == 1032 || buttonCode == 1033)
                {
                    Log.Write("Window has correct size ratio, wp is: " + e.wp + ", needsAction is: " + needsAction);
                    if (Convert.ToBoolean(e.wp) && !needsAction)
                    {
                        Log.Write("Needs action now");

                        // Update children
                        UpdateChildren();

                        // We need action now, we didn't before
                        needsAction = true;

                        // Fire event
                        requiresAction();

                        // Start timer
                        watch.Reset();
                        watch.Start();

                        // Update last action date
                        lastRequiredAction = DateTime.Now;
                    }
                    else if (needsAction && !Convert.ToBoolean(e.wp))
                    {
                        Log.Write("No longer needs action");

                        // We don't need action any more
                        needsAction = false;

                        // Fire event
                        noLongerRequiresAction();

                        // Stop timer
                        watch.Stop();
                        cumulativeResponseTime += watch.ElapsedMilliseconds;
                        actionCount++;

                        // Update last action date
                        lastRequiredAction = DateTime.Now;
                    }

                    actionButtonsVisible = Convert.ToBoolean(e.wp);
                }
                else if (buttonCode == 1035)                         // "DEAL ME IN"
                {
                    Log.Write("Window is sitting out text, wp is: " + e.wp + ", IsSittingOut is: " + IsSittingOut);

                    if (Convert.ToBoolean(e.wp) && !IsSittingOut)
                    {
                        Log.Write("Sitting out now");

                        // We're sitting out now, we didn't before
                        IsSittingOut = true;

                        sittingOut();
                    }
                    else if (IsSittingOut && !Convert.ToBoolean(e.wp))
                    {
                        Log.Write("No longer sitting out");

                        // We're not sitting out any longer
                        IsSittingOut = false;
                    }
                }
                break;
            }
        }