Exemple #1
0
        private void HotKeyPressed(object sender, HotKeyManager.HotKeyEventArgs e)
        {
            bool lockTaken = false;

            try
            {
                m_SpinLock.Enter(ref lockTaken);

                if (e.Modifiers == 0 && m_CurrentItem != null)
                {
                    SpinWait.SpinUntil(() => !HotKeyManager.IsKeyPressed(e.Key));

                    if (m_KeyHook_KEYS.Contains(e.Key))
                    {
                        long buyPrice = m_CurrentItem.BuyPrice + 1;

                        if (CopperValue >= 0)
                        {
                            buyPrice = (long)((Math.Floor(m_CurrentItem.BuyPrice / 100.0) * 100) + CopperValue);

                            if (buyPrice <= m_CurrentItem.BuyPrice + 1)
                            {
                                buyPrice += 100;
                            }
                        }

                        long buyPriceC = (buyPrice % 100);
                        long buyPriceS = (long)(Math.Floor(buyPrice / 100.0) % 100);
                        long buyPriceG = (long)(Math.Floor(buyPrice / 10000.0));

                        switch (m_CurrentState)
                        {
                        case HandlerState.SEARCH:
                            SendKeys.Send(m_CurrentItem.Name);
                            m_CurrentState = HandlerState.ENTERG;
                            break;

                        case HandlerState.ENTERG:
                            SendKeys.Send(buyPriceG.ToString());
                            m_CurrentState = HandlerState.ENTERS;
                            break;

                        case HandlerState.ENTERS:
                            SendKeys.Send(buyPriceS.ToString());
                            m_CurrentState = HandlerState.ENTERC;
                            break;

                        case HandlerState.ENTERC:
                            SendKeys.Send(buyPriceC.ToString());
                            m_CurrentState = HandlerState.NEXT;
                            break;

                        case HandlerState.NEXT:
                            m_CurrentItem  = null;
                            m_CurrentState = HandlerState.SEARCH;
                            break;
                        }
                    }
                    else if (m_KeyHook_KEYS_SKIP.Contains(e.Key))
                    {
                        m_CurrentItem  = null;
                        m_CurrentState = HandlerState.SEARCH;
                    }
                }
            }
            finally
            {
                if (lockTaken)
                {
                    m_SpinLock.Exit();
                }
            }
        }
Exemple #2
0
        private void HotKeyPressed(object sender, HotKeyManager.HotKeyEventArgs e)
        {
            bool lockTaken = false;
            try
            {
                m_SpinLock.Enter(ref lockTaken);

                if (e.Modifiers == 0 && m_CurrentItem != null)
                {
                    SpinWait.SpinUntil(() => !HotKeyManager.IsKeyPressed(e.Key));

                    if (m_KeyHook_KEYS.Contains(e.Key))
                    {
                        long buyPrice = m_CurrentItem.BuyPrice + 1;

                        if (CopperValue >= 0)
                        {
                            buyPrice = (long)((Math.Floor(m_CurrentItem.BuyPrice / 100.0) * 100) + CopperValue);

                            if (buyPrice <= m_CurrentItem.BuyPrice + 1)
                                buyPrice += 100;
                        }

                        long buyPriceC = (buyPrice % 100);
                        long buyPriceS = (long)(Math.Floor(buyPrice / 100.0) % 100);
                        long buyPriceG = (long)(Math.Floor(buyPrice / 10000.0));

                        switch (m_CurrentState)
                        {
                            case HandlerState.SEARCH:
                                SendKeys.Send(m_CurrentItem.Name);
                                m_CurrentState = HandlerState.ENTERG;
                                break;
                            case HandlerState.ENTERG:
                                SendKeys.Send(buyPriceG.ToString());
                                m_CurrentState = HandlerState.ENTERS;
                                break;
                            case HandlerState.ENTERS:
                                SendKeys.Send(buyPriceS.ToString());
                                m_CurrentState = HandlerState.ENTERC;
                                break;
                            case HandlerState.ENTERC:
                                SendKeys.Send(buyPriceC.ToString());
                                m_CurrentState = HandlerState.NEXT;
                                break;
                            case HandlerState.NEXT:
                                m_CurrentItem = null;
                                m_CurrentState = HandlerState.SEARCH;
                                break;
                        }
                    }
                    else if (m_KeyHook_KEYS_SKIP.Contains(e.Key))
                    {
                        m_CurrentItem = null;
                        m_CurrentState = HandlerState.SEARCH;
                    }
                }
            }
            finally
            {
                if (lockTaken)
                    m_SpinLock.Exit();
            }
        }