Comments (12)
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.
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.
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.
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.
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.
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.
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.
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.
@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.
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.
Awesome, thanks!
from keyboard.
Now available at https://github.com/boppreh/mouse and pip install mouse
, though it's still somewhat experimental.
from keyboard.
Related Issues (20)
- Capture the activation of a hotkey while other keys are being pressed HOT 1
- Sometimes the keys are not pressed
- Using exit(0) inside on_press_key() lambda doesn't exit the program
- Keys like "D" Counting as other keys HOT 1
- keyboard.suppress blocks keyboard.is_pressing
- TOO MANY dependencies HOT 3
- suppress=True breaks shift-click selection in Notepad, Explorer
- suppress=True breaks Windows Start Menu HOT 3
- Key name '~' in not mapped to any known key
- 'right alt' and 'left alt' parsable hotkeys behaves the same as the 'alt' parsable hotkey on Windows
- suppress=True doesn't work with read_hotkey and on_release_key HOT 1
- How to stop `Keyboard.hook` hooking `keyboard.send` or `keyboard.write`?
- Alt Down not detected with Streamdeck
- Returns upper and lower cases on Windows but only lower cases on Linux
- An OSError when the device is unplugged on RaspberrypiOS HOT 2
- Suddenly not working in mac os
- Periodicaly produce a TypeError: object of type 'NoneType' has no len()
- Cannot hold a key
- 'LMB + Ctrl' mulfunctions when `suppress = True`
- German and English Keyboard. Mixed letters (Z<-->Y)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keyboard.