SavinaRoja / PyUserInput

A module for cross-platform control of the mouse and keyboard in python that is simple to install and use.
GNU General Public License v3.0
1.07k stars 244 forks source link

PyKeyboard on autostart does not work #85

Open Werner91 opened 8 years ago

Werner91 commented 8 years ago

Hi,

I'm using PyKeyboard in two of my three python scripts. All three scripts run in a while loop. The script without PyKeyboard runs how it should. But the other two scripts are not running when I boot my Pi. The scripts are execute able. When I run them manually everything works fine.

I added

exec 2> /tmp/rc.local.debug
set -x" 

into

/etc/rc.local

to check whats the issue. I found out there must be a problem with the line:

....
"k=PyKeyboard()"
...

So do I have to autostart something for PyUserInput befor I start the Script wich uses it? Sorry I'm new to Linux and Python.

Thanks.

pepijndevos commented 8 years ago

Make sure X11 is running before you start the script.

moses-palmer commented 8 years ago

PyUserInput on Linux requires an active X session. X is the application on most Linux systems that is responsible for managing the display, and mouse and keyboard input.

When you have logged in to the environment---I assume you use a graphical desktop environment---the X server will be running, but when /etc/rc.local is loaded, it is not.

A solution would be to start your script as an autostart application. How to do this depends on your desktop environment.

Werner91 commented 8 years ago

Thanks, now it works :)