Package: macmouse
mouseThis version of mouse is published from a forked repository. It is reproduced under the MIT license. For the original mouse project, please lookhere.Take full control of your mouse with this small Python library. Hook global events, register hotkeys, simulate mouse movement and clicks, and much more.Huge thanks toKirill Pavlovfor donating the package name. If you are looking for the Cheddargetter.com client implementation,pip install mouse==0.5.0.FeaturesGlobal event hook on all mice devices (captures events regardless of focus).Listenandsendsmouse events.Works withWindowsandLinuxas mouse, not MacMouse. This is a seperate project (the original) and can be installed viasudo pip install mouseWorks withMacOS(requires granting accessibility permissions to terminal/python in System Preferences -> Security & Privacy)Pure Python, no C modules to be compiled.Python 2 and 3.Includeshigh level API(e.g.recordandplay.Events automatically captured in separate thread, doesn't block main program.Tested and documented.This program makes no attempt to hide itself, so don't use it for keyloggers.UsageInstall thePyPI package:$ pip install macmouseor clone the repository (no installation required, source files are sufficient):$ git clone https://github.com/gansel51/mouseKnown limitations:Other applications, such as some games, may register hooks that swallow all key events. In this casemousewill be unable to report events.APITable of Contentsmouse.ButtonEventmouse.DOUBLEmouse.DOWNmouse.LEFTmouse.MIDDLEmouse.MoveEventmouse.RIGHTmouse.UPmouse.WheelEventmouse.Xmouse.X2mouse.versionmouse.is_pressedmouse.press(aliases:hold)mouse.releasemouse.clickmouse.double_clickmouse.right_clickmouse.wheelmouse.movemouse.dragmouse.on_buttonmouse.on_clickmouse.on_double_clickmouse.on_right_clickmouse.on_middle_clickmouse.waitmouse.get_positionmouse.hookmouse.unhookmouse.unhook_allmouse.recordmouse.play(aliases:replay)class mouse.ButtonEventButtonEvent(event_type, button, time)ButtonEvent.buttonAlias for field number 1ButtonEvent.count(self, value, /)Return number of occurrences of value.ButtonEvent.event_typeAlias for field number 0ButtonEvent.index(self, value, start=0, stop=9223372036854775807, /)Return first index of value.Raises ValueError if the value is not present.ButtonEvent.timeAlias for field number 2mouse.DOUBLE='double'mouse.DOWN='down'mouse.LEFT='left'mouse.MIDDLE='middle'class mouse.MoveEventMoveEvent(x, y, time)MoveEvent.count(self, value, /)Return number of occurrences of value.MoveEvent.index(self, value, start=0, stop=9223372036854775807, /)Return first index of value.Raises ValueError if the value is not present.MoveEvent.timeAlias for field number 2MoveEvent.xAlias for field number 0MoveEvent.yAlias for field number 1mouse.RIGHT='right'mouse.UP='up'class mouse.WheelEventWheelEvent(delta, time)WheelEvent.count(self, value, /)Return number of occurrences of value.WheelEvent.deltaAlias for field number 0WheelEvent.index(self, value, start=0, stop=9223372036854775807, /)Return first index of value.Raises ValueError if the value is not present.WheelEvent.timeAlias for field number 1mouse.X='x'mouse.X2='x2'mouse.version='0.7.1'mouse.is_pressed(button='left')[source]Returns True if the given button is currently pressed.mouse.press(button='left')[source]Presses the given button (but doesn't release).mouse.release(button='left')[source]Releases the given button.mouse.click(button='left')[source]Sends a click with the given button.mouse.double_click(button='left')[source]Sends a double click with the given button.mouse.right_click()[source]Sends a right click with the given button.mouse.wheel(delta=1)[source]Scrolls the wheeldeltaclicks. Sign indicates direction.mouse.move(x, y, absolute=True, duration=0, steps_per_second=120.0)[source]Moves the mouse. Ifabsolute, to position (x, y), otherwise move relative
to the current position. Ifdurationis non-zero, animates the movement.
The fps of the animation is determined by 'steps_per_second', default is 120.mouse.drag(start_x, start_y, end_x, end_y, absolute=True, duration=0)[source]Holds the left mouse button, moving from start to end position, then
releases.absoluteanddurationare parameters regarding the mouse
movement.mouse.on_button(callback, args=(), buttons=('left', 'middle', 'right', 'x', 'x2'), types=('up', 'down', 'double'))[source]Invokescallbackwithargswhen the specified event happens.mouse.on_click(callback, args=())[source]Invokescallbackwithargswhen the left button is clicked.mouse.on_double_click(callback, args=())[source]Invokescallbackwithargswhen the left button is double clicked.mouse.on_right_click(callback, args=())[source]Invokescallbackwithargswhen the right button is clicked.mouse.on_middle_click(callback, args=())[source]Invokescallbackwithargswhen the middle button is clicked.mouse.wait(button='left', target_types=('up', 'down', 'double'))[source]Blocks program execution until the given button performs an event.mouse.get_position()[source]Returns the (x, y) mouse position.mouse.hook(callback)[source]Installs a global listener on all available mouses, invokingcallbackeach time it is moved, a key status changes or the wheel is spun. A mouse
event is passed as argument, with type eithermouse.ButtonEvent,mouse.WheelEventormouse.MoveEvent.Returns the given callback for easier development.mouse.unhook(callback)[source]Removes a previously installed hook.mouse.unhook_all()[source]Removes all hooks registered by this application. Note this may include
hooks installed by high level functions, such asrecord.mouse.record(button='right', target_types=('down',))[source]Records all mouse events until the user presses the given button.
Then returns the list of events recorded. Pairs well withplay(events).Note: this is a blocking function.
Note: for more details on the mouse hook and events seehook.mouse.play(events, speed_factor=1.0, include_clicks=True, include_moves=True, include_wheel=True)[source]Plays a sequence of recorded events, maintaining the relative time
intervals. If speed_factor is <= 0 then the actions are replayed as fast
as the OS allows. Pairs well withrecord().The parametersinclude_*define if events of that type should be inluded
in the replay or ignored.