Giter Site home page Giter Site logo

Comments (12)

boppreh avatar boppreh commented on June 19, 2024 1

Good news everyone!

I've contacted the current owner of the mouse package and they agreed to transfer ownership of the name. So I'll be releasing a sister library to keyboard under the name of mouse, containing the code that's currently at from keyboard import mouse.

This is by far the best resolution I could hope for. Stay tune for news.

from keyboard.

boppreh avatar boppreh commented on June 19, 2024 1

I'm not sure if I should post here, open another issue, or wait for the ownership transfer and a new repo. Anyway, I would like a mouse.drag function. It's nothing more than a combination of press, move, and release, but I find writing and using this helper function a lot.

Here; 85a4162

Unrelated, I'm getting some errors on the mouse listening parts. I'll have to investigate.

from keyboard.

boppreh avatar boppreh commented on June 19, 2024

Hi

Take a look at https://github.com/boppreh/keyboard/blob/master/keyboard/mouse.py

It's available as from keyboard import mouse. It's not official, but functional.

from keyboard.

xiangxw avatar xiangxw commented on June 19, 2024

I see, thanks a lot.
By the way, how can I identify the hwnd of a mouse or keyboard event?
Can this library be used in PyQt program ?

from keyboard.

boppreh avatar boppreh commented on June 19, 2024

The events detected are global. There's no notion of "window", or window handlers. You can call GetForegroundWindow to get the foreground window, maybe through ctypes or win32gui, but there's no direct support in this library.

And I'm not sure if it would work with a PyQt program, because the Windows backend that handles keyboard events is its own Windows message-loop (https://github.com/boppreh/keyboard/blob/master/keyboard/_winkeyboard.py#L430). That may or may not interfere with the Qt event loop, you would have to test it. If you do, please post the results, that would be very useful to know.

If it doesn't work for PyQt, you may have more luck with a PyQt specific solution, such as https://pypi.python.org/pypi/PyGlobalShortcut/0.2.3 .

from keyboard.

xiangxw avatar xiangxw commented on June 19, 2024

Hi, keyboard can be used with PyQt. But it will freeze input dialog sometimes, and I can't move the mouse. Maybe we should not call SetWindowsHookEx in anothor thread? or can we call SetWindowsHookEx in main thread and use Qt's main loop to do pythoncom.PumpMessages(), just like pyHook do? Thanks.

from keyboard.

s0hv avatar s0hv commented on June 19, 2024

I solved the freezing by moving pythoncom.PumpMessages() to the Qt loop using a QTimer

timer = QTimer()
timer.timeout.connect(pythoncom.PumpWaitingMessages())
timer.setInterval(10)  # Call pythoncom.PumpWaitingMessages() around 100 times per second
timer.start()

This seems to fix the problem for me but I haven't done any extensive testing so it might still freeze in some situations.

from keyboard.

dino8890 avatar dino8890 commented on June 19, 2024

What are the requirements to consider mouse for release, at least the Windows version?

Since I need mouse hooks for the project I'm working on, I might contribute on the way as well(even though the functionality implemented so far is enough).

from keyboard.

boppreh avatar boppreh commented on June 19, 2024

@Doom8890 It's already available as from keyboard import mouse. There's no documentation page, but you can easily see what functions are available at https://github.com/boppreh/keyboard/blob/master/keyboard/mouse.py .

from keyboard import mouse
mouse.move(100, 200)
mouse.double_click()

You can also listen for events, record and replay macros. It's quite similar to keyboard, but simpler because there's less buttons and no layouts to worry about.

It's not "official", and not documented in the main page, because I think from keyboard import mouse looks silly and I can't think of any appropriate package name that isn't in use and wouldn't cause confusion with other similar packages. Is there anything you need that is not available at the moment?

from keyboard.

klvbdmh avatar klvbdmh commented on June 19, 2024

Is there anything you need that is not available at the moment?

I'm not sure if I should post here, open another issue, or wait for the ownership transfer and a new repo. Anyway, I would like a mouse.drag function. It's nothing more than a combination of press, move, and release, but I find writing and using this helper function a lot.

from keyboard.

klvbdmh avatar klvbdmh commented on June 19, 2024

Awesome, thanks!

from keyboard.

boppreh avatar boppreh commented on June 19, 2024

Now available at https://github.com/boppreh/mouse and pip install mouse, though it's still somewhat experimental.

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.