Exemple #1
0
        private void timerFeed_Tick(object sender, EventArgs e)
        {
            if (m_charInfo.Homunculus_Hungry <= m_setup.MaxFeedValue)
            {
                switch (m_setup.Action)
                {
                case FeedAction.FeedButton:
                    if (WinAPI.GetActiveWindow() != m_process.WindowHandle)
                    {
                        WinAPI.SetActiveWindow(m_process.WindowHandle);

                        lblText.Text = "FeedButton";

                        SendInputManager.MouseClick(m_setup.LocationFeedButton.X, m_setup.LocationFeedButton.Y, 100);

                        m_setup.Action    = FeedAction.Delay;
                        m_setup.DelayTime = DateTime.Now;
                    }
                    break;

                case FeedAction.Delay:
                    if (DateTime.Now.Subtract(m_setup.DelayTime).TotalSeconds >= 4)
                    {
                        lblText.Text = "ConfirmButton";

                        m_setup.Action = FeedAction.FeedConfirmButton;
                    }
                    else
                    {
                        lblText.Text = string.Format("Delay: {0:n0}",
                                                     4 - DateTime.Now.Subtract(m_setup.DelayTime).TotalSeconds);
                    }
                    break;

                case FeedAction.FeedConfirmButton:
                    if (WinAPI.GetActiveWindow() != m_process.WindowHandle)
                    {
                        WinAPI.SetActiveWindow(m_process.WindowHandle);

                        lblText.Text = string.Empty;

                        SendInputManager.MouseClick(m_setup.LocationFeedConfirmButton.X, m_setup.LocationFeedConfirmButton.Y, 100);

                        m_setup.LastFeedTime = DateTime.Now;
                        m_setup.Action       = FeedAction.FeedButton;
                    }
                    break;
                }
            }
        }
Exemple #2
0
        public override string ToString()
        {
            switch (Type)
            {
            case MacroActionType.Delay:
                return(string.Format("{0:00}:{1:00}:{2:0000}",
                                     Delay.Value.Minutes,
                                     Delay.Value.Seconds,
                                     Delay.Value.Milliseconds));

            case MacroActionType.Key:
                return(SendInputManager.GetKeyDescription(Key.Value));

            default:
                return(string.Empty);
            }
        }
 public VKeyItem(VKey key)
 {
     m_key        = key;
     m_desription = SendInputManager.GetKeyDescription(key);
 }
        private void bwMacro_DoWork(object sender, DoWorkEventArgs e)
        {
            foreach (MacroAction action in m_macro.Actions)
            {
                if (bwMacro.CancellationPending)
                {
                    break;
                }
                else
                {
                    bool reportedWaiting = false;
                    while (!bwMacro.CancellationPending && WinAPI.GetForegroundWindow() != m_processManager.WindowHandle)
                    {
                        if (!reportedWaiting)
                        {
                            bwMacro.ReportProgress(0, "Waiting..");
                            reportedWaiting = true;
                        }
                        Thread.Sleep(10);
                    }

                    if (!bwMacro.CancellationPending)
                    {
                        switch (action.Type)
                        {
                        case MacroActionType.Delay:
                            bwMacro.ReportProgress(0, "Delay");

                            int      milisecondsToWait = (int)action.Delay.Value.TotalMilliseconds;
                            DateTime startDelayTime    = DateTime.Now;

                            while (milisecondsToWait > (int)DateTime.Now.Subtract(startDelayTime).TotalMilliseconds)
                            {
                                if (bwMacro.CancellationPending)
                                {
                                    break;
                                }
                                else
                                {
                                    Thread.Sleep(10);
                                }
                            }

                            break;

                        case MacroActionType.Key:
                            bwMacro.ReportProgress(0, "Key: " + SendInputManager.GetKeyDescription(action.Key.Value));

                            SendInputManager.SendInput(action.Key.Value);

                            break;
                        }
                    }
                }
            }

            if (bwMacro.CancellationPending)
            {
                e.Cancel = true;
            }
        }