Пример #1
0
        public bool KeyDownGlobal(Hooking.GlobalKeyEventHandlerArgs e)
        {
            if (e.VirtualKeyCode == _config.RecordShortcut)
            {
                if (_recorder.IsRunning)
                {
                    stopMacro();
                }
                else
                {
                    lblStatus.Text = "Status: Recording";
                    _recorder.Clear();
                    _recorder.StartRecording();
                }
                return(false);
            }
            if (e.VirtualKeyCode == _config.PlayShortcut)
            {
                if (_player.IsPlaying)
                {
                    _player.CancelPlayback();
                }
                else
                {
                    playMacro();
                }
                return(false);
            }
            if (e.VirtualKeyCode == _config.CaptureShortcut && _recorder.IsRunning)
            {
                string basePath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" + _config.FilePrefix;

                if (!System.IO.Directory.Exists(basePath))
                {
                    Directory.CreateDirectory(basePath);
                }

                Guid   guid     = Guid.NewGuid();
                string tempPath = basePath + "\\" + _config.FilePrefix + guid + ".bmp";

                int offsetPointx = int.Parse(_config.Offset.Split(',')[0]) * _config.CaptureWidth / 100;
                int offsetPointy = int.Parse(_config.Offset.Split(',')[1]) * _config.CaptureHeight / 100;

                //System.Drawing.Point destinationPoint = new System.Drawing.Point((int)_recorder.CurrentXY.X + _config.CaptureWidth, (int)_recorder.CurrentXY.Y + _config.CaptureHeight);
                System.Drawing.Point destinationPoint = new System.Drawing.Point((int)_recorder.CurrentXY.X + offsetPointx, (int)_recorder.CurrentXY.Y + offsetPointy);
                //System.Drawing.Point sourcePoint = new Point((int)_recorder.CurrentXY.X, (int)_recorder.CurrentXY.Y);
                System.Drawing.Point sourcePoint = new Point((int)_recorder.CurrentXY.X - offsetPointx, (int)_recorder.CurrentXY.Y - offsetPointy);
                ImageProcessing.CaptureImage(sourcePoint, destinationPoint, tempPath, "bmp");

                _recorder.CurrentMacro.AddEvent(new MacroWaitImageEvent(tempPath.Replace("\\", "\\\\")));
                return(false);
            }

            return(true);
        }
Пример #2
0
        private static void RecordActions(string outputDirectory)
        {
            var recorder = new MacroRecorder();

            recorder.StartRecording();
            Console.Write("Press <Enter> to end recording... ");
            while (Console.ReadKey().Key != ConsoleKey.Enter)
            {
            }
            recorder.StartRecording();
        }
Пример #3
0
        private void RecordBtn_Click(object sender, EventArgs e)
        {
            if (_recorder.CurrentMacro != null && _recorder.CurrentMacro.Events.Length > 0)
            {
                var result = MessageBox.Show(this,
                                             "This will continue appending to your current macro," +
                                             "would you like to start over and clear the current macro?",
                                             "Clear Macro?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    _recorder.Clear();
                }
                else if (result == DialogResult.Cancel)
                {
                    return;
                }
            }
            MacroLogLV.Items.Clear();
            StopWatch.Restart();
            StopWatch.Start();
            MacroTimer.Start();
            _recorder.StartRecording();
            _recorder.CurrentMacro.OnKeyTrigger   += CurrentMacro_OnKeyTrigger;
            _recorder.CurrentMacro.OnMouseTrigger += CurrentMacro_OnMouseTrigger;
            StatusLabel.Text = "Status: Recording...";
        }
Пример #4
0
        private void btnStartRecord_Click(object sender, EventArgs e)
        {
            // confirm action
            if (_recorder.CurrentMacro != null && _recorder.CurrentMacro.Events.Length > 0)
            {
                var result = MessageBox.Show("This will continue appending to your current macro, would you like to start over and clear the current macro>", "Clear macro?", MessageBoxButtons.YesNoCancel,
                                             MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    _recorder.Clear();
                }
                else if (result == DialogResult.Cancel)
                {
                    return;
                }
            }

            // start recording
            lblStatus.Text = "Recording...";
            _recorder.StartRecording();
        }
Пример #5
0
        private void recordControlButton_Click(object sender, EventArgs e)
        {
            // Confirm action.
            if (_recorder.CurrentMacro != null && _recorder.CurrentMacro.Events.Length > 0)
            {
                var result = MessageBox.Show(_languages.GetLocalizedString("confirm_append_message"),
                                             _languages.GetLocalizedString("confirm_append_title"), MessageBoxButtons.YesNoCancel,
                                             MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    _recorder.Clear();
                }
                else if (result == DialogResult.Cancel)
                {
                    return;
                }
            }

            // Begin recording.
            _recorder.StartRecording();
        }