Beispiel #1
0
        private void PlayThread()
        {
            using (StreamReader fs = new StreamReader(macro_path))
            {
                bool   input_params = true;
                int    original_width, original_height;
                int    diferencia_width = 0, diferencia_height = 0;
                string line;
                int    PlayTickRate = 0;
                while ((line = fs.ReadLine()) != null)
                {
                    if (playing)
                    {
                        string[] parametros = line.Split('>');
                        if (input_params)
                        {
                            original_width    = Int32.Parse(parametros[1].Trim());
                            original_height   = Int32.Parse(parametros[2].Trim());
                            diferencia_width  = Screen.PrimaryScreen.Bounds.Width - original_width;
                            diferencia_height = Screen.PrimaryScreen.Bounds.Height - original_height;
                            if (parametros[3] == null)
                            {
                                PlayTickRate = 8;
                            }
                            else
                            {
                                PlayTickRate = Int32.Parse(parametros[3]);
                            }
                            OnPlayStarted(this, new OnPlayStartEventArgs(filename, macro_path, PlayTickRate));
                            input_params = false;
                        }
                        else
                        {
                            if (Hooks.CurrentKey != null)
                            {
                                OnKeyPressed(this, new OnKeyPressedEventArgs(Hooks.CurrentKeyCode, Hooks.CurrentKey));
                            }
                            //X: parametros[1]
                            //Y: parametros[2]
                            //Key: parametros[3]
                            //clicked?: parametros[4]
                            if (parametros[3] != "none" && parametros[3].Length > 0)
                            {
                                keybd_event(byte.Parse(parametros[3]), 0x45, 0, 0);
                            }
                            if (bool.Parse(parametros[4].Trim()))
                            {
                                mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)Int32.Parse(parametros[1].Trim()), (uint)Int32.Parse(parametros[2].Trim()), 0, 0);
                            }
                            if (bool.Parse(parametros[5].Trim()))
                            {
                                mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, (uint)Int32.Parse(parametros[1].Trim()), (uint)Int32.Parse(parametros[2].Trim()), 0, 0);
                            }
                            Cursor.Position = new Point(Int32.Parse(parametros[1].Trim()) + diferencia_width, Int32.Parse(parametros[2].Trim()) + diferencia_height);
                        }
                    }
                    else
                    {
                        break;
                    }
                    Thread.Sleep(PlayTickRate);
                }
                fs.Close();
            }

            Hooks.stop();
            if (OnPlayFinished != null)
            {
                OnPlayFinished(this, new OnPlayFinishedEventArgs(filename, macro_path));
            }
        }
Beispiel #2
0
 public void FinishRecord()
 {
     recording = false;
     OnRecordFinished(this, new OnRecordFinishedEventArgs(filename, macro_path));
     Hooks.stop();
 }