Giter Site home page Giter Site logo

Mouse support schedule about keyboard HOT 9 CLOSED

boppreh avatar boppreh commented on June 19, 2024
Mouse support schedule

from keyboard.

Comments (9)

boppreh avatar boppreh commented on June 19, 2024 1

@glitchassassin I understand and agree. But I'm not going down this path for the simplistic reason that I got lucky with the package name "keyboard" and I can't think of any way to describe the combo mouse+keyboard, while:

  • being different enough from other active packages and libraries (there's tons of pyinput);
  • being short and easy to remember ("was it keyboard_and_mouse or mouse_and_keyboard? ");
  • being available on PyPI.

As you can see this is quite petty, so any and all suggestions are appreciated.

from keyboard.

boppreh avatar boppreh commented on June 19, 2024

It's already available as from keyboard import mouse, and has been there for a while. It has a very similar API to the keyboard module itself, with hook, record, play, press, etc. It's not documented on the main page because I find it counter intuitive to have mouse support inside a package named keyboard.

Any suggestions on how to solve this dilemma are appreciated, as is feedback on the module itself.

from keyboard.

boppreh avatar boppreh commented on June 19, 2024

Here's a basic API docs for the functions available:

API

Table of Contents

class keyboard.mouse.ButtonEvent

ButtonEvent(event_type, button, time)

ButtonEvent.button

Alias for field number 1

ButtonEvent.count(...)

T.count(value) -> integer -- return number of occurrences of value

ButtonEvent.event_type

Alias for field number 0

ButtonEvent.index(...)

T.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.

ButtonEvent.time

Alias for field number 2

keyboard.mouse.DOUBLE

= 'double'

keyboard.mouse.DOWN

= 'down'

keyboard.mouse.LEFT

= 'left'

keyboard.mouse.MIDDLE

= 'middle'

class keyboard.mouse.MoveEvent

MoveEvent(x, y, time)

MoveEvent.count(...)

T.count(value) -> integer -- return number of occurrences of value

MoveEvent.index(...)

T.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.

MoveEvent.time

Alias for field number 2

MoveEvent.x

Alias for field number 0

MoveEvent.y

Alias for field number 1

keyboard.mouse.RIGHT

= 'right'

keyboard.mouse.UP

= 'up'

class keyboard.mouse.WheelEvent

WheelEvent(delta, time)

WheelEvent.count(...)

T.count(value) -> integer -- return number of occurrences of value

WheelEvent.delta

Alias for field number 0

WheelEvent.index(...)

T.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.

WheelEvent.time

Alias for field number 1

keyboard.mouse.X

= 'x'

keyboard.mouse.X2

= 'x2'

keyboard.mouse.is_pressed(button='left')

[source]

Returns True if the given button is currently pressed.

keyboard.mouse.press(button='left')

[source]

Presses the given button (but doesn't release).

keyboard.mouse.release(button='left')

[source]

Releases the given button.

keyboard.mouse.click(button='left')

[source]

Sends a click with the given button.

keyboard.mouse.double_click(button='left')

[source]

Sends a double click with the given button.

keyboard.mouse.right_click()

[source]

Sends a right click with the given button.

keyboard.mouse.move(x, y, absolute=True, duration=0)

[source]

Moves the mouse. If absolute, to position (x, y), otherwise move relative
to the current position. If duration is non-zero, animates the movement.

keyboard.mouse.on_button(callback, args=(), buttons=('left', 'middle', 'right', 'x', 'x2'), types=('up', 'down', 'double'))

[source]

Invokes callback with args when the specified event happens.

keyboard.mouse.on_click(callback, args=())

[source]

Invokes callback with args when the left button is clicked.

keyboard.mouse.on_double_click(callback, args=())

[source]

Invokes callback with args when the left button is double clicked.

keyboard.mouse.on_right_click(callback, args=())

[source]

Invokes callback with args when the right button is clicked.

keyboard.mouse.on_middle_click(callback, args=())

[source]

Invokes callback with args when the middle button is clicked.

keyboard.mouse.wait(button='left', target_types=('up', 'down', 'double'))

[source]

Blocks program execution until the given button performs an event.

keyboard.mouse.get_position()

[source]

Returns the (x, y) mouse position.

keyboard.mouse.hook(callback)

[source]

Installs a global listener on all available mouses, invoking callback
each time it is moved, a key status changes or the wheel is spun. A mouse
event is passed as argument, with type either mouse.ButtonEvent,
mouse.WheelEvent or mouse.MoveEvent.

Returns the given callback for easier development.

keyboard.mouse.unhook(callback)

[source]

Removes a previously installed hook.

keyboard.mouse.unhook_all()

[source]

Removes all hooks registered by this application. Note this may include
hooks installed by high level functions, such as record.

keyboard.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 with play(events).

Note: this is a blocking function.
Note: for more details on the mouse hook and events see hook.

keyboard.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 with record().

The parameters include_* define if events of that type should be inluded
in the replay or ignored.

keyboard.mouse.replay

Alias for play.

from keyboard.

NicoPy avatar NicoPy commented on June 19, 2024

It's already available as from keyboard import mouse, and has been there for a while.

Sorry for that. As on the main page, it is written "Mouse support coming soon." I didn't look further.
Thanks

from keyboard.

boppreh avatar boppreh commented on June 19, 2024

No need to apologize, the mouse submodule is supposed to hidden. Otherwise people will start depending on its API and have trouble when it's moved somewhere else, like a separate package.

And thank you for your interest in this library. Every piece of feedback makes it better.

from keyboard.

glitchassassin avatar glitchassassin commented on June 19, 2024

For what it's worth, I think it makes perfect sense to keep mouse & keyboard functionality together in the same library. System APIs usually tap both kinds of devices (at least for Windows). Why not Python modules?

Cheers,

from keyboard.

NicoPy avatar NicoPy commented on June 19, 2024

so any and all suggestions are appreciated.

mouse+keyboard = mouboard or meyboard
keyboard+mouse = keyse or keyboase
😁

from keyboard.

boppreh avatar boppreh commented on June 19, 2024

Don't tempt me. I'm going to register them on PyPI as aliases for this package, with credits to you, then we can both share the embarrassment.

from keyboard.

NicoPy avatar NicoPy commented on June 19, 2024

Ha Ha ! Not even afraid ! 😛

from keyboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.