Esempio n. 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);
                }
            }
        }
Esempio n. 2
0
 public KBMActionStrategy(IntPtr hookedInstance)
 {
     kbmHOOK = new KBMLLHook(hookedInstance);
     kbmActionRecorder = new KBMActionRecorderLinq();
     kbmSimulator = new KBMSimulator();
 }
Esempio n. 3
0
 public void KBMActionRecorderLinqConstructorTest1()
 {
     KBMActionRecorderLinq target = new KBMActionRecorderLinq();
     Assert.IsNotNull(target);
 }
Esempio n. 4
0
 public void KBMActionRecorderLinqConstructorTest()
 {
     string actionsListFileName = "actionsListFileName"; // TODO: Initialize to an appropriate value
     KBMActionRecorderLinq target = new KBMActionRecorderLinq(actionsListFileName);
     Assert.IsNotNull(target);
 }
Esempio n. 5
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);
 }
Esempio n. 6
0
 public void GetMouseActionDatasTest()
 {
     KBMActionRecorderLinq target = new KBMActionRecorderLinq();
     target.WriteData("WM_LBUTTONDOWN", new MSLLHOOKSTRUCT() { pt = new Win32API.POINT(0, 0) }, 10);
     target.SaveActions();
     Win32API.MouseEvent[] expected = new Win32API.MouseEvent[]
     {
          new Win32API.MouseEvent() 
         {
             delayTime = 10, 
             dwFlags = Miku.Client.Win32API.MouseEventFlag.LeftDown ,
             pt=new Win32API.POINT(0, 0)
         }
     };
     Win32API.MouseEvent[] actual;
     actual = target.GetMouseActionDatas();
     Assert.AreEqual(expected[0], actual[0]);
 }
Esempio n. 7
0
        public void GetKeyboardActionDatasTest()
        {
            KBMActionRecorderLinq target = new KBMActionRecorderLinq();
            target.WriteData(KeyboardEvents.WM_KeyDown.ToString(), Keys.A, 10);
            target.SaveActions();
            Win32API.KeyEvent[] expected = new Win32API.KeyEvent[]
            {
                new Win32API.KeyEvent()
                {
                    dwFlags = Miku.Client.Win32API_Accessor.KBEventFlag.KeyDown,
                    bVk = Convert.ToInt32(Keys.A),
                    delayTime = 10
                }
            };
            Win32API.KeyEvent[] actual;
            actual = target.GetKeyboardActionDatas();

            Assert.AreEqual(expected[0], actual[0]);
        }
Esempio n. 8
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]);
 }