예제 #1
0
        public override void StartPlaybackWithExistingFile(string filePath)
        {
            KBMActionRecorderLinq tmpKbmActionRecorder = new KBMActionRecorderLinq(filePath);
            KBMSimulator kbmSimulator = new KBMSimulator();

            object[] actions = tmpKbmActionRecorder.GetDatas();

            Thread.Sleep(1000);

            foreach (var item in actions)
            {
                if (item is Win32API.MouseEvent)
                {
                    kbmSimulator.Simulate(((Win32API.MouseEvent)item).dwFlags, ((Win32API.MouseEvent)item).pt.x, ((Win32API.MouseEvent)item).pt.y, 0, UIntPtr.Zero);
                    Thread.Sleep(((Win32API.MouseEvent)item).delayTime);
                }
                else if (item is Win32API.KeyEvent)
                {
                    kbmSimulator.Simulate(((Win32API.KeyEvent)item).bVk, ((Win32API.KeyEvent)item).vScan, ((Win32API.KeyEvent)item).dwFlags, ((Win32API.KeyEvent)item).dwExtraInfo);
                    Thread.Sleep(((Win32API.KeyEvent)item).delayTime);
                }
            }
        }
예제 #2
0
 public void WriteDataTest()
 {
     KBMActionRecorderLinq target = new KBMActionRecorderLinq(); 
     string keyEvents = KeyboardEvents.WM_KeyDown.ToString(); 
     Keys myKey = Keys.A; 
     int delayTime = 10; 
     target.WriteData(keyEvents, myKey, delayTime);
     target.SaveActions();
     Win32API.KeyEvent Expected = new Win32API.KeyEvent()
     {
         dwFlags = Miku.Client.Win32API_Accessor.KBEventFlag.KeyDown,
         bVk = Convert.ToInt32(Keys.A),
         delayTime = 10
     };
     var actual = target.GetDatas()[0];
     Assert.AreEqual(Expected, actual);
 }
예제 #3
0
 public void GetDatasTest()
 {
     KBMActionRecorderLinq target = new KBMActionRecorderLinq();
     target.WriteData("WM_LBUTTONDOWN", new MSLLHOOKSTRUCT() { pt = new Win32API.POINT(0, 0) }, 10);
     target.SaveActions();
     target.WriteData(KeyboardEvents.WM_KeyDown.ToString(), Keys.A, 10);
     target.SaveActions();
     object[] expected = new object[] 
     { 
         new Win32API.MouseEvent() 
         {
             delayTime = 10, 
             dwFlags = Miku.Client.Win32API.MouseEventFlag.LeftDown ,
             pt=new Win32API.POINT(0, 0)
         },
         new Win32API.KeyEvent()
         {
             dwFlags = Miku.Client.Win32API_Accessor.KBEventFlag.KeyDown,
             bVk = Convert.ToInt32(Keys.A),
             delayTime = 10
         }
     };            
     object[] actual;
     actual = target.GetDatas();
     Assert.AreEqual(expected[0], actual[0]);
     Assert.AreEqual(expected[1], actual[1]);
 }