Coder Social home page Coder Social logo

pyuserinput's Introduction

PyUserInput

PyUserInput is a group project so we've moved the project over to a group organization: https://github.com/PyUserInput/PyUserInput . That is now the active development repository and I'll be phasing this one out, so please go there for the latest code and to post new issues. This should be corrected on PyPI in the next version update of PyUserInput.

A module for cross-platform control of the mouse and keyboard in python that is simple to use.

Mouse control should work on Windows, Mac, and X11 (most Linux systems). Scrolling is implemented, but users should be aware that variations may exist between platforms and applications.

Keyboard control works on X11(linux) and Windows systems. Mac control is a work in progress.

Dependencies

Depending on your platform, you will need the following python modules for PyUserInput to function:

  • Linux - Xlib
  • Mac - Quartz, AppKit
  • Windows - pywin32, pyHook

How to get started

After installing PyUserInput, you should have pymouse and pykeyboard modules in your python path. Let's make a mouse and keyboard object:

from pymouse import PyMouse
from pykeyboard import PyKeyboard

m = PyMouse()
k = PyKeyboard()

Here's an example of clicking the center of the screen and typing "Hello, World!":

x_dim, y_dim = m.screen_size()
m.click(x_dim/2, y_dim/2, 1)
k.type_string('Hello, World!')

PyKeyboard allows for a range of ways for sending keystrokes:

# pressing a key
k.press_key('H')
# which you then follow with a release of the key
k.release_key('H')
# or you can 'tap' a key which does both
k.tap_key('e')
# note that that tap_key does support a way of repeating keystrokes with a interval time between each
k.tap_key('l',n=2,interval=5) 
# and you can send a string if needed too
k.type_string('o World!')

and it supports a wide range of special keys:

#Create an Alt+Tab combo
k.press_key(k.alt_key)
k.tap_key(k.tab_key)
k.release_key(k.alt_key)

k.tap_key(k.function_keys[5])  # Tap F5
k.tap_key(k.numpad_keys['Home'])  # Tap 'Home' on the numpad
k.tap_key(k.numpad_keys[5], n=3)  # Tap 5 on the numpad, thrice

Note you can also send multiple keystrokes together (e.g. when accessing a keyboard shortcut) using the press_keys method:

# Mac example
k.press_keys(['Command','shift','3'])
# Windows example
k.press_keys([k.windows_l_key,'d'])

Consistency between platforms is a big challenge; Please look at the source for the operating system that you are using to help understand the format of the keys that you would need to send. For example:

# Windows
k.tap_key(k.alt_key)
# Mac
k.tap_key('Alternate')

I'd like to make a special note about using PyMouseEvent and PyKeyboardEvent. These objects are a framework for listening for mouse and keyboard input; they don't do anything besides listen until you subclass them. I'm still formalizing PyKeyboardEvent, so here's an example of subclassing PyMouseEvent:

from pymouse import PyMouseEvent

def fibo():
    a = 0
    yield a
    b = 1
    yield b
    while True:
        a, b = b, a+b
        yield b

class Clickonacci(PyMouseEvent):
    def __init__(self):
        PyMouseEvent.__init__(self)
        self.fibo = fibo()

    def click(self, x, y, button, press):
        '''Print Fibonacci numbers when the left click is pressed.'''
        if button == 1:
            if press:
                print(self.fibo.next())
        else:  # Exit if any other mouse button used
            self.stop()

C = Clickonacci()
C.run()

Intended Functionality of Capturing in PyUserInput

For PyMouseEvent classes, the variables "capture" and "capture_move" may be passed during instantiation. If capture=True is passed, the intended result is that all mouse button input will go to your program and nowhere else. The same is true for capture_move=True except it deals with mouse pointer motion instead of the buttons. Both may be set simultaneously, and serve to prevent events from propagating further. If you notice any bugs with this behavior, please bring it to our attention.

A Short Todo List

These are a few things I am considering for future development in PyUserInput:

  • Ensuring that PyMouse capturing works for all platforms
  • Implement PyKeyboard capturing (add PyKeyboardEvent for Mac as well)
  • PyMouse dynamic delta scrolling (available in Mac and Windows, hard to standardize)
  • Make friends with more Mac developers, testing help is needed...

Many thanks to

Pepijn de Vos - For making PyMouse and allowing me to modify and distribute it along with PyKeyboard.

Jack Grigg - For contributions to cross-platform scrolling in PyMouse.

pyuserinput's People

Contributors

aravinda0 avatar balloob avatar casebeer avatar davinnovation avatar dhiltonp avatar diogotito avatar gumpcraca avatar jhosmer avatar jnv avatar mikkelam avatar moses-palmer avatar pepijndevos avatar pythonian4000 avatar savinaroja avatar sqxccdy avatar talv avatar trafficone avatar willwade avatar young001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyuserinput's Issues

Problem in excution of multiple keys on different windows

I am runing two chrome browser via selenium, all I want to do is open a website in both and save html, I am using pyuserinput keyboard to simulate ctrl+s(save first html) and alt+tab(change browser) and ctrl+s(save second html) , however when I run the script most of time it only save first browser and move to second browser but no simulate ctrl+s on second browser. Can you help me about this issue.

Press Shift not working

I cloned the repository and installed.
"Finished processing dependencies for PyUserInput==0.1.9"
Then I did the following...
me$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import pykeyboard
kb = pykeyboard.PyKeyboard()
kb.press_key(kb.shift_key)

No error was thrown, but my machine is not acting like 'shift' was pressed.

I'm on Mac 10.9.3

error on PyKeyboardEvent (ubuntu)

class ClickKeyEventListener(PyKeyboardEvent):
   def tap(self, keycode, character, press):
      print 'KBCLICK:', keycode, character, press

if __name__ == '__main__':
   mainHook=ClickKeyEventListener()
   mainHook.run() #start()

ERROR:

line 396, in configure_keys
    modifier_mapping = self.display.get_modifier_mapping()
AttributeError: 'ClickKeyEventListener' object has no attribute 'display'

Help me pls 😄

Capture mouse and keyboard events at the same time

Hi,

It would be nice to be able to capture mouse and keyboard events at the same time. Currently this doesn't seem to be possible because each event class starts an endless loop.

Best Regards,
Jonas

Side-effects of clicking mouse buttons

When PyMouse.click() is executed on X11-based systems, the following events are currently generated: move(x, y), press button, move(x, y), release button. The second move(x, y) has an unexpected side effect on some systems (tested on ROSA Desktop Fresh with KDE).

If, for example, I open a file in a text editor, select some text there and emulate a right-click (call PyMouse.click(x, y, button=2)) on the selected area, the context menu appears as it should, the first item of the menu gets selected due to that mouse move event and then - activated when the button is released. That first item was "Cut (Ctrl-X)" in Kwrite on my system, so the selected text was cut while one would expect only the context menu to show up.

To avoid such side effects of clicking, PyMouse.move() could, for example, generate "move" events only if the position of the mouse should actually change. Something like this:

    def move(self, x, y):
        if (x, y) != self.position():
            fake_input(self.display, X.MotionNotify, x=x, y=y)
            self.display.sync()

Multiple key tap

IDK if it already exists, if it does please tell me how.

Anyway. It would be really nice if you could tap multiple keys at once, for instance ALT + TAB. Also, is there a way to listen for specific strings? For instance, if I write "close", could the program catch that string and then execute a function?

How to listen for key events via PyKeyboardEvent

Compared to PyMouseEvent, PyKeyboardEvent event handling is deficient in two ways:

  1. It uses two functions (key_press and key_release) instead of a single function with a toggle argument.
  2. The underlying event processing does not provide abstracted key information, making cross-platform key event handling difficult.

To address this I am proposing that key_press and key_release be combined into a single function like PyMouseEvent.click(), and I wish to modify the internal event handling to pass abstracted key information to the function. Essentially the user should be able to write a handler rule for something like "shift_left" or "k" and it should work on all systems. To do this the names of keys should probably be standardized (like the mouse buttons are in PyMouse) and passed instead of the keycodes (or probably alongside them). Some difficulty might be introduced however by overloaded keys which generate different characters or events depending on masks such as Shift/Alt/Fn/Lock. I am open to suggestions and I will begin testing potential solutions.

Keyboard capture in X11 causes an error (Python 3)

After subclassing PyKeyboardEvent and setting self.capture = True I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
    self.run()
  File "/home/pi/.local/lib/python3.2/site-packages/pykeyboard/x11.py", line 286, in run
    self.display2.screen().root.grab_keyboard(True, X.KeyPressMask | X.KeyReleaseMask, X.GrabModeAsync, X.GrabModeAsync, 0, 0, X.CurrentTime)
TypeError: grab_keyboard() takes exactly 5 positional arguments (8 given)

This is obvious by looking into python3-xlib source. Maybe the API changed from python-xlib?

The following fix works for me: https://github.com/jnv/PyUserInput/commit/81da6dfb9c056f40623c085dda86c6aae80857d9 though I'm not quite sure I got the arguments right. It captures the keyboard and releases it with a workaround suggested in #48.

Error with symbols

Using the program to type the < and > symbols is inconsistent. I can't find a reason why this would be the way that it is. See below for test code and the output. This is on Ubuntu 14.04 with us keyboard.

import time
from pykeyboard import PyKeyboard

k = PyKeyboard()
time.sleep(3)
k.tap_key('a')
time.sleep(1)
k.tap_key('A')
time.sleep(1)
k.tap_key('greater')
time.sleep(1)
k.tap_key('less')
time.sleep(1)
k.tap_key('<')
time.sleep(1)
k.tap_key('>') 

The output is:
aA.<>>
As you can see, greater outputs the correct key, but without a shift. Also < and > output the same key.

Windows Keyboard event listening

I've noticed that the Windows implementation of pykeyboard does not currently work. This is due to private key_press and key_release not calling their respective public functions.

PyMouse & Mac

Readme.md Line 37

x_dim, y_dim = m.screen(size)

should be

x_dim, y_dim = m.screen_size()

But any reason why this takes a long long time to run on the Mac? (like 30 odd seconds)

python setup.py develop fails

[ppai@pp PyUserInput]$ sudo python setup.py develop
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'develop'

Can you use setuptools instead of distutils ?

dont catch emulated events

my problem:
i want to catch mouse (and keyboard) events, check conditions, and in one case return this event to system, in another case - return another event to system.
for example i want to transform mouseWheelUp into keyPress(w), but other mouse events must work without changes.

from pymouse import *
mouse=PyMouse()
from pykeyboard import *
kbrd=PyKeyboard()

class hook(PyMouseEvent):
   def __init__(self):
      PyMouseEvent.__init__(self)

   def click(self, x, y, button, press):
      print 'MOUSECLICK:', button, press
      if not press: return
      if button==4: #wheelUp
         kbrd.tap_key('w') #emulate W button
      else:
         mouse.click(x, y, button) #return original event to system

if __name__ == '__main__':
   mainHook=hook()
   mainHook.captwure = True
   # mainHook.daemon = True
   mainHook.start() #start()
   while True:
      time.sleep(0.1)

this code doesnt work 😠

[Enhancement] Provide a "wheel" method for pymouse

I am using PyMouse for my application and it corresponds perfectly to my needs! Thank you very much. Yet, I want to be allowed to scroll within my app with the wheel (not a middle click). Is it possible to provide this easily within PyMouse?

I have never used XLib, so I have no idea how to implement it by myself.

Thank you very much, I really appreciate your module.

Prevent Keyboard Actions while still listening

Hi, Is it possible to listen to user's keyboard actions using pyKeyboard but does not allow the system to react to the actions.

For example, say the user pressed ALT + TAB.. We have to detect that he pressed those buttons, but we should prevent the system to take action for the ALT+TAB.. Like the PyHook for instance..

Thanks in Advance..

Function `click` does not transform argument to `int` automatically

I tried the code in readme but got error like this:

>>> x_dim, y_dim = m.screen_size()
>>> m.click(x_dim/2, y_dim/2, 1)
Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    m.click(x_dim/2, y_dim/2, 1)
  File "C:\Python34\lib\site-packages\pymouse\base.py", line 56, in click
    self.press(x, y, button)
  File "C:\Python34\lib\site-packages\pymouse\windows.py", line 32, in press
    self.move(x, y)
  File "C:\Python34\lib\site-packages\pymouse\windows.py", line 70, in move
    windll.user32.SetCursorPos(x, y)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: Don't know how to convert parameter 1

This is because x_dim/2 is 960.0 not 960.

So, add a type coercions or modify the readme.

Is PyUserInput works on all fedora,RedHat related or debian related os

Hi I am new to python ,so can we use PyUserInput on fedora or redhat related os , I am using Debian 7 and PyuserInput is working fine . for installing PyuserInput I use 'pip install PyuserInput' but for fedora related os, is this command works fine ? means fedora and redhat use rpm and yum so , is that possible to use pip on fedora related os. and How can we install PyuserInput and python-xlib on fedora related os?
Regards,
Dhairyashil

PyMouseEvent stop method bug

PyMouseEvent stop() method works only when called inside the click() handler. The listener is not stopped when stop() method is called from outside (e.g. by another module). In such situation it still keeps listening for all mouse events - the stop() methods doesn't seem to work. Surprisingly it's not the case with the PyKeyboardEvent - the stop() methods works fine there.

k.type_string('\Sigma') gives 'ßSigma'

The following code

from pykeyboard import PyKeyboard
k = PyKeyboard()
k.type_string(classification_guess)

gives:

ßSigma

I have Python 3.4.2, Ubuntu 14.10 (MATE), PyUserInput 0.1.9 (installed via pip).

Syntax Error while installing

[ppai@pp PyUserInput]$ sudo python setup.py install
running install
running build
running build_py
running install_lib
byte-compiling /usr/lib/python2.7/site-packages/pykeyboard/mac.py to mac.pyc
  File "/usr/lib/python2.7/site-packages/pykeyboard/mac.py", line 74
    'return' = 0x24,
             ^
SyntaxError: invalid syntax

running install_egg_info
Removing /usr/lib/python2.7/site-packages/PyUserInput-0.1.9-py2.7.egg-info
Writing /usr/lib/python2.7/site-packages/PyUserInput-0.1.9-py2.7.egg-info

My setup

[ppai@pp PyUserInput]$ python -V
Python 2.7.5
[ppai@pp PyUserInput]$ uname -a
Linux pp 3.13.9-200.fc20.x86_64 #1 SMP Fri Apr 4 12:13:05 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[ppai@pp PyUserInput]$ cat /etc/redhat-release 
Fedora release 20 (Heisenbug)
[ppai@pp PyUserInput]$ 

Using type_string, less than sign is replaced by greater than sign

k = PyKeyboard()

k.type_string('<')

Expected output: <
Actual output: >

I noticed this first because I was trying to scan in an xml file and use PyKeyboard to put it into a form online. Unfortunately it turned every single < into >

Is there already a fix for this?

PyKeyboard issue

Hi, and thanks for this incredible software. I'm trying to send "CTRL_l + 1" (a shortcut for Push-to-Talk) to the Mumble client (http://mumble.sourceforge.net/) but nothing happens, if I send ALT + o it opens the Configure menu so it is targeting the right window. Am I missing something? I'm on a Raspberry Pi if that is of any difference.

import subprocess, os, time, pykeyboard

os.environ['DISPLAY'] = ':0.0'
subprocess.Popen('XAUTHORITY=/home/pi/.Xauthority DISPLAY=:0 /usr/bin/xdotool search --onlyvisible --name Mumble windowactivate', shell=True)

k = pykeyboard.PyKeyboard()
k.press_key(k.control_l_key)
k.press_key('1')
time.sleep(2)
k.release_key('1')
k.release_key(k.control_l_key)

xlib.xauth:warning, no xauthority details available

Dear sirs,

I use ubuntu 12.04 desktop.

In the command "python", hereunder

from pykeyboard import PyKeyboard
k = PyKeyboard()
Xlib.xauth:warning, no xauthority details available
xlib.protocol.request.QueryExtension
Xlib.xauth:warning, no xauthority details available
xlib.protocol.request.QueryExtension

It may cause the Xauthority under ubuntu 12.04 Desktop

how to solve it?
thanks

dependency problem

Hi !

$ sudo pip install PyUserInput.
$ python

from pymouse import PyMouseEvent
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/pymouse/init.py", line 41, in
from .x11 import PyMouse, PyMouseEvent
File "/usr/local/lib/python2.7/dist-packages/pymouse/x11.py", line 16, in
from Xlib.display import Display
ImportError: No module named Xlib.display

Dependencies to python-xlib is missing.

Keep up the good work and thanks for your library !

Problem in excution of multiple keys on different windows

I am runing two chrome browser via selenium, all I want to do is open a website in both and save html, I am using pyuserinput keyboard to simulate ctrl+s(save first html) and alt+tab(change browser) and ctrl+s(save second html) , however when I run the script most of time it only save first browser and move to second browser but no simulate ctrl+s on second browser. Can you help me about this issue.

Including PyUserInput in another project

Hi
Apologies for what is very much a beginners question. I was hoping to include PyUserInput in a project I'm working on https://github.com/TimSmith714/Remote-MC-Control It's a remote control solution for Minecraft inspired by wanting to help a disabled friend play Minecraft using her Eye Tracking software. I'm not sure how I'd go about arranging the PyUserInput files in the project folder to make sure that I leave all the proper licenses in the proper place. Should I create a PyUserInput folder to include the files as they are here?
Thanks
Tim

Import PyHook only if PyKeyboardEvent used and on Windows.

For the PyKeyboardEvent class an extra dependency is required on Windows: PyHook.

This means that if you only want to simulate keyboard input you require users to install an extra dependency that is not used and during runtime you import a module that is not being used.

This can be solved in multiple ways:

  1. Import pyhook in the constructor of PyKeyboardEvent on Windows
  2. Surround import PyHook with a try, catch for ImportError and issue a warning when PyKeyboardEvent is used but PyHook was not imported
  3. Move PyKeyboardEvent to a separate (sub)module.

Solution 1 and 3 keep memory usage to the minimum as the module is only imported if used.

In case of solution 1 the module can be imported twice if two listeners are initiated. This is not too bas Python overhead to import a certain module twice is small.

mac import problem

When I attempt to run the fibonacci example code, I get this error:

Traceback (most recent call last):
File "pymouse.py", line 1, in
from pymouse import PyMouseEvent
File "/Users/mfenner/Desktop/pymouse.py", line 1, in
from pymouse import PyMouseEvent
ImportError: cannot import name PyMouseEvent

when I try to import pymouse, I get the same error. Any idea what's wrong with my install?

EDIT: I checked and the modules are all in my site packages and python does recognize them, the import just fails

Second instance of PyMouseEvent crashes

Hi, all. I'm new to Python so maybe this is not an actual problem?

Here is the code:

class ClickEventListener(PyMouseEvent):
   def click(self, x, y, button, press):
      if press:
         my_callback()

m = ClickEventListener()
m.start()
m.stop()

n = ClickEventListener()
n.start()
n.stop()

The first instance m works all right but the second instance n doesn't work. And when I stop thread n, an exception is raised:

Exception AttributeError: "'HookManager' object has no attribute 'keyboard_hook'"
 in <bound method HookManager.__del__ of <pyHook.HookManager.HookManager object at 0x027B5830>>
 ignored

Does anyone know why? Thanks!

examples not working on mac..

I may be being stupid..

from pymouse import PyMouse
from pykeyboard import PyKeyboard

m = PyMouse()
k = PyKeyboard()

dir(k)  #Use dir() on a PyKeyboard instance
k.numpad_keys.viewkeys()
k.function_keys

gives:
AttributeError: 'PyKeyboard' object has no attribute 'numpad_keys'
(and if I comment the numpad line)
AttributeError: 'PyKeyboard' object has no attribute 'function_keys'

(running latest zip on mac)

The initial readme could do with a one liner on how to send a normal key as well as a function key..

k.type_string method doesn't work as expected

Hello. I try this small code piece.

from pymouse import PyMouse
from pykeyboard import PyKeyboard

m = PyMouse()
k = PyKeyboard()

x_dim, y_dim = m.screen_size()
m.click(x_dim/2, y_dim/2, 1)
k.type_string("hello")

Instead of "hello" it writes "odllt" string. Any ideas. Thanks

Qwartz - Quartz

If I'm not mistaken the references to "Qwartz" should be Quartz right?

The python setup.py install will fail as no package Qwartz exists..

Thanks! :)

Mac needs character to keycode translation table

Running this example code:

from pykeyboard import PyKeyboard
k = PyKeyboard()
k.type_string('Hello, World!')

Gives:

python test.py
Traceback (most recent call last):
File "test.py", line 3, in
k.type_string('Hello, World!')
File "/Library/Python/2.7/site-packages/pykeyboard/base.py", line 47, in type_string
self.tap_key(i)
File "/Library/Python/2.7/site-packages/pykeyboard/base.py", line 39, in tap_key
self.press_key(character)
File "/Library/Python/2.7/site-packages/pykeyboard/mac.py", line 22, in press_key
event = CGEventCreateKeyboardEvent(None, key, True)
ValueError: depythonifying 'unsigned short', got 'str'

Multimouse control

Hello guys, can I use PyUserInput to control multiple coursors?
Thank you in advance.

character vs keycode

It is obviously very convenient to be able to press both characters and keycodes, but I would think a common mapping exists between the two.

Do you think it would make sense to hoist some of that logic to base.py?

At the very least is_char_shifted should be in base.py I think.

After some more reading, I'm not sure what to believe anymore. Some people say ascii codes should be the same, while others say they might even differ depending on keyboard layout.

Maybe we can normalise to Java keycodes and I don't know, do something nice. I'm just going to hack together some Mac keyboard stuff now, dodging all issues.

Xlib.error.XError on second click wait run

Hello,

I am having an issue where waiting for a mouse click a second time results in an error within Xlib.

Versions

OS: Ubuntu 14.04LTS
xlib version: 15rc1 (i have tried numerous versions)
pyuserinput version: 1.0

Implementation

class ClickToggle(PyMouseEvent):
    def __init__(self):
        PyMouseEvent.__init__(self)

    def click(self, x, y, button, press):
        if press:
            self.stop()

Elsewhere in the program I need to wait for a mouse event so I do the following:

C = ClickToggle()
c.run()

This works fine the first time, however, the second time this happens it results in an Xlib.error. Traceback below.

Traceback (most recent call last):
  File "window_control.py", line 168, in <module>
    controller = KioskWindowControl()
  File "window_control.py", line 56, in __init__
    self.__idle_loop()
  File "window_control.py", line 154, in __idle_loop
    self.__primary_ad_loop()
  File "window_control.py", line 131, in __primary_ad_loop
    self.toggle.run()
  File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/pymouse/x11.py", line 130, in run
    self.display2.record_enable_context(self.ctx, self.handler)
  File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/Xlib/ext/record.py", line 240, in enable_context
    context = context)
  File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/Xlib/ext/record.py", line 217, in __init__
    apply(rq.ReplyRequest.__init__, (self, ) + args, keys)
  File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/Xlib/protocol/rq.py", line 1430, in __init__
    self.reply()
  File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/Xlib/protocol/rq.py", line 1450, in reply
    raise self._error
Xlib.error.XError: <class 'Xlib.error.XError'>: code = 153, resource_id = 73400320, sequence_number = 10, major_opcode = 146, minor_opcode = 5

Note: I am interacting with Xlib.display in my program.

Let me know if I can provide any additional information.

Kevin

printing @ signs

I have a problem printing the "@" sign when using type_string. Anyone knows why?
I have UTF-8 as encoding.

pykeyboard is not working on windows 64-bit systems

I tried pyuserinput on 64-bit windows system, had installed followed components:

python-2.7.6.amd64
pywin32-217.win-amd64-py2.7
pyHook-1.5.1.win-amd64-py2.7

mouse is working fine, but keyboard event is not working...help

Using multiple instances of PyUserInput, windowed

I saw this question on StackOverflow:

I'm using PyUserInput and I want to run multiple python scripts in separate windows is it possible to make the script run inside of a window while still allowing me to do other things with my mouse and keyboard simultaneously? I'm using the latest version of ubuntu and python 2.7.3

how can I attach python code to a window?

I think this is an interesting question. I think it might be possible, but certainly not at the moment. I'll need to research and think about it, does anyone have any insight into how to implement this?

Pyinstaller - Error at runtime

Executing an application created with pyinstaller using PyUserInput results in the following runtime error on OSX:

Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "/Library/Python/2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "path/build/server/out00-PYZ.pyz/pymouse", line 35, in <module>
  File "/Library/Python/2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "path/build/server/out00-PYZ.pyz/pymouse.mac", line 16, in <module>
  File "/Library/Python/2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "path/build/server/out00-PYZ.pyz/Quartz", line 6, in <module>
  File "/Library/Python/2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "path/build/server/out00-PYZ.pyz/Quartz.CoreGraphics", line 9, in <module>
  File "/Library/Python/2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "/path/build/server/out00-PYZ.pyz/CoreFoundation", line 19, in <module>
  File "path/build/server/out00-PYZ.pyz/objc._bridgesupport", line 121, in initFrameworkWrapper
  File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 925, in resource_exists
  File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 1352, in has_resource
  File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 1405, in _has
NotImplementedError: Can't perform this operation for unregistered loader type

PyMouse screen_size just hangs

I recently installed PyUserInput onto my Mac (OS X Yosemite 64-bit) and attempted to get the following lines of code working:

from pymouse import PyMouse
m = PyMouse()
x_dim, y_dim = m.screen_size()

I'm using PyDev in Eclipse (Luna) with Python 2.7 and when I try to run the above code, it just hangs at the call to screen_size() - it never returns and I have to stop the interpreter.

Python3 OS X PyKeyboardEvent Crashes

I am using PyKeyboardEvent to listen for keyboard events on OS X, but Python 3 crashes when I run my instance of the subclass.

Code

>>> from pykeyboard import PyKeyboardEvent

>>> class KeyboardHandler(PyKeyboardEvent):
    def __init__(self):
        super().__init__()

    def tap(self, keycode, character, press):
        if press:
            print(character)


>>> x=KeyboardHandler()
>>> x.run()
>>> ================================ RESTART ================================

Crash Details

http://pastebin.com/6ipbyNXL

type_string character sets

this won't work;

k.type_string('I like lots of £')

Reason being is that ch_index (line 64 in base.py) is only for US keyboard layouts..
It could be over ridden but this may not be the neatest solution..

error in mac.py

it appears as though midway through the character_translate_table dict we have an error:
character_translate_table = {
...
'\t': 0x30,
'return' = 0x24,
...
as you can see, we were using : for the dict delimiter then we use = (which is obviously not supported in python)

lookup_character_value ??

What was the initial thinking behind lookup_character_value in pykeyboard base?

I'm only asking as I want to press a key based on its virtual key code.. I was guessing this function was the intention of looking up the key code and mapping it to the string form?? Happy to edit the mac, win, linux builds to do the lookup if this is the functions intention!

thanks!

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.