Skip to content

Instantly share code, notes, and snippets.

@cobrce
Created November 9, 2021 16:17
Show Gist options
  • Save cobrce/4d56f8c78d485cda0385de56b45e0831 to your computer and use it in GitHub Desktop.
Save cobrce/4d56f8c78d485cda0385de56b45e0831 to your computer and use it in GitHub Desktop.
import win32api
from interception import interception,MAX_DEVICES
from stroke import mouse_stroke
from consts import interception_mouse_flag
import time
context = interception()
mouse = 0
for i in range(MAX_DEVICES):
if interception.is_mouse(i):
mouse = i
break
# no mouse we quit
if (mouse == 0):
print("No mouse found")
exit(0)
def move(context, mouse, x, y):
resolution_width = win32api.GetSystemMetrics(0)
resolution_height = win32api.GetSystemMetrics(1)
mstroke = mouse_stroke(0, interception_mouse_flag.INTERCEPTION_MOUSE_MOVE_ABSOLUTE.value, 0, int(x * 0xFFFF / resolution_width), int(y * 0xFFFF / resolution_height), 0)
context.send(mouse, mstroke) # we send the key stroke, now the right button is down
def interpolate(x1,y1,x2,y2,step):
x = 0
last_x = x2 - x1
a = (y2 - y1) / (last_x)
for x in range(0,last_x,step):
yield ((x + x1),(x*a + y1))
x,y = win32api.GetCursorPos()
gen = interpolate(x,y,x+100,y+300,3)
for x,y in gen:
move(context,mouse,x,y)
time.sleep(.0001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment