Mousers / mousetrap

MouseTrap
http://live.gnome.org/MouseTrap
GNU General Public License v2.0
0 stars 1 forks source link

#115 Convert keyPressed() method #161

Closed JESchulz closed 9 years ago

amarocchini commented 9 years ago

I am looking into this with Max

max12187 commented 9 years ago

I found that an easy way to do this is to use the "tkinter" gui library. It lets us create a keypress event and offers more gui options if we would like them in the future. I'm going to proceed to implement this library with our code.

max12187 commented 9 years ago

An issue I found with using the tkinter library is that it will only pick up key presses when the window it creates is active. But our program will be clicking around and selecting other windows. I'm trying to find a way to get around this.

StoneyJackson commented 9 years ago

Hmmm... since MouseTrap is GNOME, you should probably stick with GTK (instead of Tcl/Tk which is what tkinter wraps). Since this is just a spike implementation, it's probably not a problem. Just don't get married to it.

You might look in gui.py to see how MouseTrap implements Pointer to see how to do things with GTK and XLib. Or you could simply import gui.py and use Pointer directly. Since Pointer doesn't really use its config object, you could instantiate and use a Pointer like this:

## Untested
from mousetrap.gui import Pointer
pointer = Pointer(None)
pointer.set_position(x, y)
(x, y) = pointer.get_position()
pointer.click()

Now, if on the other hand you find a way to replace XLib with Wayland... that would be awesome. We need to figure out how to move that way eventually anyway. That's the way GNOME is going. I don't know if this has any impact on what you are doing. I thought I'd mention it just in case.

max12187 commented 9 years ago

This in now irrelevant. It is not necessary for the spike.