Exemplo n.º 1
0
        private void PlaySimpleMacro()
        {
            IsPlaying = true;

            lock (monitor)
            {
                while (true)
                {
                    foreach (MacroEvent current in CurrentSimpleMacro.Events)
                    {
                        if (cancelled)
                        {
                            cancelled = false;
                            return;
                        }


                        if (current is MacroDelayEvent)
                        {
                            MacroDelayEvent castEvent = (MacroDelayEvent)current;


                            Random rand = new Random();

                            int nextRand = rand.Next(0, (int)castEvent._rand);

                            Console.WriteLine(nextRand);

                            Monitor.Wait(monitor, (int)castEvent._delay + nextRand);


                            if (cancelled)
                            {
                                cancelled = false;
                                return;
                            }
                        }
                        else

                        if (current is MacroKeyEvent)
                        {
                            MacroKeyEvent castEvent = (MacroKeyEvent)current;
                            keyboardSimulator.SetTargetWindow();
                            keyboardSimulator.SendSimulatedInput(castEvent.GetKeycode());
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public string GetKey()
        {
            MacroKeyEvent castKey = (MacroKeyEvent)_key;

            return(castKey.ToString());
        }
Exemplo n.º 3
0
        public bool HasKey()
        {
            MacroKeyEvent castKey = (MacroKeyEvent)_key;

            return(castKey.HasKey());
        }