[Python] Fwd: pynput: help request.

Gabriele Battaglia iz4apu a libero.it
Mar 24 Lug 2018 12:02:51 CEST


Ciao.
Avevo chiesto, ad una comunità online di Python, un aiuto per capirci 
qualcosa di questa libreria, avrei voluto vedere un esempio di 
funzionamento.
Posto qui il mio messaggio originale, se qualcuno ha uno script 
funzionante che la include, potrebbe inviarmelo, per favore?

Grazie in anticipo.

-------- Messaggio Inoltrato --------
Oggetto: pynput: help request.
Data: Wed, 8 Nov 2017 15:25:06 +0100
Mittente: Gabriele Battaglia <iz4apu a libero.it>
A: pythonvis a freelists.org

Hello everybody.

I always wanted to know a way to read the input from keyboard, without 
stopping the main flow of the python script. input statement does that 
so it isnt worth for my puorpose.
It's hard to find something that works fine under Win, Mac and Linux as 
those O.S have different ways to dialogue with their keyboard.
I ended with a script which worked very well but now I'm migrating to 
Python 3.6 and I've discovered that it doesn't work any longer. So, I 
must find a different solution.
I tried Pygame module, which has a great control over the keyboard but 
it requires a video mode on. In this video mode I can send any text 
output to the console. So my scripts can't generate text, neither 
prompting something to the user. Pygame must be descarded for this reason.
Later I tried a module called keyboard 0.11.0 but I found it complex and 
I wasn't able to understand how it works.
And recently I landed on this library called pynput. This seems what I 
need to. It is compatible both for 2 and 3 python and cross platform. 
Moreover it controls both keyboard and mouse, if needed.

You may read its keyboard control module here:

https://pynput.readthedocs.io/en/latest/keyboard.html#monitoring-the-keyboard

The problem is that my knoledge in Python seems to be not enaugh to 
understand exactly how to use it in my scripts. The examples works but...
How do I start the keyboard Listener and how do I get the key pressed?

Is there someone available to help me, please?
This module will help a lot in a script: while you're waiting the user 
pressing a key, main program can continue running. And there is no need 
to press enter after giving a key command: the effect where immediate taken.

Thanks in advance.

Gabriele.

-- 
Gabriele Battaglia, IZ4APU (Libero)
Sent from TB on Windows 10, Genus Bononiae's computer.


Maggiori informazioni sulla lista Python