Ejemplo n.º 1
0
 public Boolean SetCursorPosition(Int32 x, Int32 y, Boolean useWinAPI = false, Boolean useWinAPIOnly = false)
 {
     if (useWinAPIOnly)
     {
         if (useWinAPI)
         {
             return(NativeMethods.SetCursorPos(x, y));
         }
     }
     else
     {
         if (this.CanSimulateInput)
         {
             Stroke stroke = new Stroke();
             stroke.Mouse.X     = (Int32)((x - VirtualScreenOriginLeft) * (65535d / (VirtualScreenWidth - 1)));
             stroke.Mouse.Y     = (Int32)((y - VirtualScreenOriginTop) * (65535d / (VirtualScreenHeight - 1)));
             stroke.Mouse.Flags = MouseFlags.MoveAbsolute;
             if (useWinAPI)
             {
                 return(InputInterceptor.Send(this.Context, this.AnyDevice, ref stroke, 1) == 1 && NativeMethods.SetCursorPos(x, y));
             }
             else
             {
                 return(InputInterceptor.Send(this.Context, this.AnyDevice, ref stroke, 1) == 1);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
 public Boolean MoveCursorBy(Int32 dX, Int32 dY, Boolean useWinAPI = false, Boolean useWinAPIOnly = false)
 {
     if (useWinAPIOnly)
     {
         if (useWinAPI)
         {
             Win32Point point = this.GetCursorPosition();
             return(NativeMethods.SetCursorPos(point.X + dX, point.Y + dY));
         }
     }
     else
     {
         if (this.CanSimulateInput)
         {
             Stroke stroke = new Stroke();
             stroke.Mouse.X     = dX;
             stroke.Mouse.Y     = dY;
             stroke.Mouse.Flags = MouseFlags.MoveRelative;
             if (useWinAPI)
             {
                 Win32Point point = this.GetCursorPosition();
                 return(InputInterceptor.Send(this.Context, this.AnyDevice, ref stroke, 1) == 1 && NativeMethods.SetCursorPos(point.X + dX, point.Y + dY));
             }
             else
             {
                 return(InputInterceptor.Send(this.Context, this.AnyDevice, ref stroke, 1) == 1);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
 public Boolean SetMouseState(MouseState state, Int16 rolling = 0)
 {
     if (this.CanSimulateInput)
     {
         Stroke stroke = new Stroke();
         stroke.Mouse.State   = state;
         stroke.Mouse.Rolling = rolling;
         return(InputInterceptor.Send(this.Context, this.AnyDevice, ref stroke, 1) == 1);
     }
     return(false);
 }
Ejemplo n.º 4
0
 public Boolean SetKeyState(KeyCode code, KeyState state)
 {
     if (this.CanSimulateInput)
     {
         Stroke stroke = new Stroke();
         stroke.Key.Code  = code;
         stroke.Key.State = state;
         return(InputInterceptor.Send(this.Context, this.AnyDevice, ref stroke, 1) == 1);
     }
     return(false);
 }