rshk / python-libxdo

Python bindings for libxdo
BSD 3-Clause "New" or "Revised" License
76 stars 19 forks source link

using CURRENTWINDOW is not obvious #10

Closed dkg closed 8 years ago

dkg commented 8 years ago

Maybe i'm missing something, but i don't see how to use CURRENTWINDOW with this library:

In [1]: import xdo
In [2]: x = xdo.Xdo()
In [3]: x.send_keysequence_window(CURRENTWINDOW, "foo")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-1f3e75246a3b> in <module>()
----> 1 x.send_keysequence_window(CURRENTWINDOW, "foo")

NameError: name 'CURRENTWINDOW' is not defined
In [4]: x.send_keysequence_window(xdo.CURRENTWINDOW, "foo")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-466cb20ce645> in <module>()
----> 1 x.send_keysequence_window(xdo.CURRENTWINDOW, "foo")

AttributeError: module 'xdo' has no attribute 'CURRENTWINDOW'

What am i missing?

rshk commented 8 years ago

I guess it's a constant that needs to be defined; I'll have a look

rshk commented 8 years ago

Yep, it's basically 0, so eg. this would work:

x.send_keysequence_window(ctypes.c_ulong(0), b'a')

of course it's far from nice; a first step would be to define

CURRENTWINDOW = ctypes.c_ulong(0)

but then it would probably be nice to provide some more "Pythonic" alternative -- as you suggested, a function with swapped arguments and window=CURRENTWINDOW by default..

rshk commented 8 years ago

Changed in #12, tests coming soon

rshk commented 8 years ago

Opened an "enhancement" ticket for this, see #13