示例#1
0
 private void timerReplay_Tick(EventTimerArgs e)
 {
     if (isReplaying)
     {
         while (currentInstruction.timing <= e.ElapsedMilliSeconds)
         {
             if (currentInstruction.instructionType == 0)
             {
                 MessageSender.SendKeyInput((ushort)currentInstruction.keyCode, (ushort)currentInstruction.scanCode, 0, 0);
             }
             else if (currentInstruction.instructionType == 1)
             {
                 MessageSender.SendKeyInput((ushort)currentInstruction.keyCode, (ushort)currentInstruction.scanCode, 2, 0);
             }
             else if (currentInstruction.instructionType == 2)
             {
                 MessageSender.SendLMBDown(0);
             }
             else if (currentInstruction.instructionType == 3)
             {
                 MessageSender.SendLMBUp(0);
             }
             else if (currentInstruction.instructionType == 4)
             {
                 MessageSender.SendRMBDown(0);
             }
             else if (currentInstruction.instructionType == 5)
             {
                 MessageSender.SendRMBUp(0);
             }
             else if (currentInstruction.instructionType == 6)
             {
                 MessageSender.SendMouseMove(currentInstruction.x, currentInstruction.y, 0);
             }
             else if (currentInstruction.instructionType == 7)
             {
                 MessageSender.SendXDown(0);
             }
             else if (currentInstruction.instructionType == 8)
             {
                 MessageSender.SendXUp(0);
             }
             else if (currentInstruction.instructionType == 9)
             {
                 MessageSender.SendMBDown(0);
             }
             else if (currentInstruction.instructionType == 10)
             {
                 MessageSender.SendMBUp(0);
             }
             else if (currentInstruction.instructionType == 11)
             {
                 MessageSender.SendMouseWheel(currentInstruction.mouseData, 0);
             }
             currentInstruction = recordFile.ReadNextInstruction();
         }
     }
 }
示例#2
0
        private void Tick()
        {
            stopWatch.Reset();
            stopWatch.Start();
            long lastElapsedTime = 0;

            while (isEnabled)
            {
                if ((stopWatch.ElapsedMilliseconds - lastElapsedTime >= (long)Interval))
                {
                    EventTimerArgs args = new EventTimerArgs(stopWatch.ElapsedMilliseconds, stopWatch.ElapsedMilliseconds - lastElapsedTime - Interval);
                    Elapsed(args);
                    lastElapsedTime = stopWatch.ElapsedMilliseconds;
                }
            }
        }