Esempio n. 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);
        }
Esempio n. 2
0
 private void StopBtn_Click(object sender, EventArgs e)
 {
     if (_recorder.IsRunning)
     {
         _recorder.StopRecording();
         StopWatch.Stop();
         MacroTimer.Stop();
     }
     else if (_player.IsPlaying)
     {
         _player.CancelPlayback();
     }
     StatusLabel.Text = "Status: Recording stopped";
 }
Esempio n. 3
0
 private void btnStopMacro_Click(object sender, EventArgs e)
 {
     // stop playing
     lblStatus.Text = "Macro stopped.";
     _player.CancelPlayback();
 }