Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
1,
ctypes.byref(INPUT(
type=INPUT.MOUSE,
value=INPUT_union(
mi=MOUSEINPUT(
dwFlags=MOUSEINPUT.WHEEL,
mouseData=int(dy))))),
ctypes.sizeof(INPUT))
if dx:
SendInput(
1,
ctypes.byref(INPUT(
type=INPUT.MOUSE,
value=INPUT_union(
mi=MOUSEINPUT(
dwFlags=MOUSEINPUT.HWHEEL,
mouseData=int(dx))))),
ctypes.sizeof(INPUT))
if dx or dy:
px, py = self._position_get()
self._emit('on_scroll', px, py, dx, dy)
ctypes.byref(INPUT(
type=INPUT.MOUSE,
value=INPUT_union(
mi=MOUSEINPUT(
dwFlags=MOUSEINPUT.WHEEL,
mouseData=int(dy))))),
ctypes.sizeof(INPUT))
if dx:
SendInput(
1,
ctypes.byref(INPUT(
type=INPUT.MOUSE,
value=INPUT_union(
mi=MOUSEINPUT(
dwFlags=MOUSEINPUT.HWHEEL,
mouseData=int(dx))))),
ctypes.sizeof(INPUT))
if dx or dy:
px, py = self._position_get()
self._emit('on_scroll', px, py, dx, dy)
def _press(self, button):
SendInput(
1,
ctypes.byref(INPUT(
type=INPUT.MOUSE,
value=INPUT_union(
mi=MOUSEINPUT(
dwFlags=button.value[1])))),
ctypes.sizeof(INPUT))
INPUT,
INPUT_union,
ListenerMixin,
MOUSEINPUT,
SendInput,
SystemHook)
from . import _base
class Button(enum.Enum):
"""The various buttons.
"""
unknown = None
left = (MOUSEINPUT.LEFTUP, MOUSEINPUT.LEFTDOWN)
middle = (MOUSEINPUT.MIDDLEUP, MOUSEINPUT.MIDDLEDOWN)
right = (MOUSEINPUT.RIGHTUP, MOUSEINPUT.RIGHTDOWN)
class Controller(NotifierMixin, _base.Controller):
__GetCursorPos = windll.user32.GetCursorPos
__SetCursorPos = windll.user32.SetCursorPos
def __init__(self, *args, **kwargs):
super(Controller, self).__init__(*args, **kwargs)
def _position_get(self):
point = wintypes.POINT()
if self.__GetCursorPos(ctypes.byref(point)):
return (point.x, point.y)
else:
return None
from pynput._util import NotifierMixin
from pynput._util.win32 import (
INPUT,
INPUT_union,
ListenerMixin,
MOUSEINPUT,
SendInput,
SystemHook)
from . import _base
class Button(enum.Enum):
"""The various buttons.
"""
unknown = None
left = (MOUSEINPUT.LEFTUP, MOUSEINPUT.LEFTDOWN)
middle = (MOUSEINPUT.MIDDLEUP, MOUSEINPUT.MIDDLEDOWN)
right = (MOUSEINPUT.RIGHTUP, MOUSEINPUT.RIGHTDOWN)
class Controller(NotifierMixin, _base.Controller):
__GetCursorPos = windll.user32.GetCursorPos
__SetCursorPos = windll.user32.SetCursorPos
def __init__(self, *args, **kwargs):
super(Controller, self).__init__(*args, **kwargs)
def _position_get(self):
point = wintypes.POINT()
if self.__GetCursorPos(ctypes.byref(point)):
return (point.x, point.y)
else:
def set_pos(x, y):
x = 1 + int(x * 65536./1920.)
y = 1 + int(y * 65536./1080.)
extra = ctypes.c_ulong(0)
ii_ = pynput._util.win32.INPUT_union()
ii_.mi = pynput._util.win32.MOUSEINPUT(x, y, 0, (0x0001 | 0x8000), 0, ctypes.cast(ctypes.pointer(extra), ctypes.c_void_p))
command=pynput._util.win32.INPUT(ctypes.c_ulong(0), ii_)
SendInput(1, ctypes.pointer(command), ctypes.sizeof(command))
if __name__ == "__main__":
def set_pos(x, y):
x = 1 + int(x * 65536./Wd)
y = 1 + int(y * 65536./Hd)
extra = ctypes.c_ulong(0)
ii_ = pynput._util.win32.INPUT_union()
ii_.mi = pynput._util.win32.MOUSEINPUT(x, y, 0, (0x0001 | 0x8000), 0, ctypes.cast(ctypes.pointer(extra), ctypes.c_void_p))
command=pynput._util.win32.INPUT(ctypes.c_ulong(0), ii_)
SendInput(1, ctypes.pointer(command), ctypes.sizeof(command))
if __name__ == "__main__":
def _scroll(self, dx, dy):
if dy:
SendInput(
1,
ctypes.byref(INPUT(
type=INPUT.MOUSE,
value=INPUT_union(
mi=MOUSEINPUT(
dwFlags=MOUSEINPUT.WHEEL,
mouseData=int(dy))))),
ctypes.sizeof(INPUT))
if dx:
SendInput(
1,
ctypes.byref(INPUT(
type=INPUT.MOUSE,
value=INPUT_union(
mi=MOUSEINPUT(
dwFlags=MOUSEINPUT.HWHEEL,
mouseData=int(dx))))),
ctypes.sizeof(INPUT))
if dx or dy:
px, py = self._position_get()