ing
This commit is contained in:
		
							parent
							
								
									05aa626948
								
							
						
					
					
						commit
						88c8e0354a
					
				@ -2,20 +2,25 @@ use std::mem::{size_of, transmute};
 | 
				
			|||||||
use winapi::ctypes::c_int;
 | 
					use winapi::ctypes::c_int;
 | 
				
			||||||
use winapi::shared::minwindef::DWORD;
 | 
					use winapi::shared::minwindef::DWORD;
 | 
				
			||||||
use winapi::um::winuser::{
 | 
					use winapi::um::winuser::{
 | 
				
			||||||
  GetAsyncKeyState, SendInput, INPUT, INPUT_MOUSE, LPINPUT, MOUSEEVENTF_ABSOLUTE,
 | 
					  GetAsyncKeyState, GetSystemMetrics, SendInput, INPUT, INPUT_MOUSE, LPINPUT, MOUSEEVENTF_ABSOLUTE,
 | 
				
			||||||
  MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP,
 | 
					  MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP,
 | 
				
			||||||
  MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_VIRTUALDESK,
 | 
					  MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_VIRTUALDESK,
 | 
				
			||||||
  MOUSEINPUT, VK_LBUTTON, VK_MBUTTON, VK_RBUTTON, VK_XBUTTON1, VK_XBUTTON2,
 | 
					  MOUSEINPUT, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN,
 | 
				
			||||||
 | 
					  VK_LBUTTON, VK_MBUTTON, VK_RBUTTON, VK_XBUTTON1, VK_XBUTTON2,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::mouse::{Button, ButtonState, Mouse};
 | 
					use crate::mouse::{Button, ButtonState, Mouse};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Mouse {
 | 
					impl Mouse {
 | 
				
			||||||
  pub fn move_to(absolute: bool, dx: i32, dy: i32) {
 | 
					  pub fn move_to(absolute: bool, dx: i32, dy: i32) {
 | 
				
			||||||
 | 
					    let width = unsafe { GetSystemMetrics(SM_CXVIRTUALSCREEN) };
 | 
				
			||||||
 | 
					    let height = unsafe { GetSystemMetrics(SM_CYVIRTUALSCREEN) };
 | 
				
			||||||
 | 
					    if width == 0 || height == 0 {
 | 
				
			||||||
 | 
					      return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    let pressed_left = Self::pressed(Button::Left);
 | 
					    let pressed_left = Self::pressed(Button::Left);
 | 
				
			||||||
    let pressed_right = Self::pressed(Button::Right);
 | 
					    let pressed_right = Self::pressed(Button::Right);
 | 
				
			||||||
    let pressed_middle = Self::pressed(Button::Middle);
 | 
					    let pressed_middle = Self::pressed(Button::Middle);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    let mut dw_flags = MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK;
 | 
					    let mut dw_flags = MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if absolute {
 | 
					    if absolute {
 | 
				
			||||||
@ -35,8 +40,12 @@ impl Mouse {
 | 
				
			|||||||
      type_: INPUT_MOUSE,
 | 
					      type_: INPUT_MOUSE,
 | 
				
			||||||
      u: unsafe {
 | 
					      u: unsafe {
 | 
				
			||||||
        transmute(MOUSEINPUT {
 | 
					        transmute(MOUSEINPUT {
 | 
				
			||||||
          dx,
 | 
					          dx: (dx - { GetSystemMetrics(SM_XVIRTUALSCREEN) }) * 65535 / {
 | 
				
			||||||
          dy,
 | 
					            GetSystemMetrics(SM_CXVIRTUALSCREEN)
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          dy: (dy - { GetSystemMetrics(SM_YVIRTUALSCREEN) }) * 65535 / {
 | 
				
			||||||
 | 
					            GetSystemMetrics(SM_CYVIRTUALSCREEN)
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
          mouseData: 0,
 | 
					          mouseData: 0,
 | 
				
			||||||
          dwFlags: dw_flags,
 | 
					          dwFlags: dw_flags,
 | 
				
			||||||
          time: 0,
 | 
					          time: 0,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user