Questions tagged [pynput]

pynput is a Python library for controlling and monitoring input devices.

From pynput's Python Package Index page:

This library allows you to control and monitor input devices.
Currently [as of late 2018], mouse and keyboard input and monitoring are supported.

659 questions
2
votes
1 answer

How do I properly terminate pynput calls ? Now it makes my X crash (self.socket_error)

I'm trying to capture the keyboard using the pynput ('pijnput' translates to the pit of pain :-) ) module. This my code: class KeyPress: def __init__(self,parent): self.parent=parent def on_press(self,key): …
oneindelijk
  • 606
  • 1
  • 6
  • 18
2
votes
3 answers

How do I use side mouse buttons with Pynput?

I am using the Python module Pynput to make a macro that will press one of my side buttons. Does anyone know what the side buttons are called in Pynput? For example: from pynput.mouse import Button, Controller mouse =…
Kamepoh2
  • 21
  • 1
  • 2
2
votes
1 answer

Detect key release while using keyboard module

Warning: my English sucks and also I'm really new to python So I'm making a program that requires a specific Key Press (e.g. space bar) to continue the loop, like: for i in *some sort of list*: print(something) *waits for a key* and my…
aoaaceai
  • 33
  • 1
  • 7
2
votes
1 answer

Record mouse click while key is pressed and stop recording when same key is released in python

I am creating a script where if user press f7 it will start recording mouse clicks and when he releases the button it should stop and this happens unless user close the program. I have written a code which starts recording keys on pressing f7 but…
2
votes
2 answers

pynput mouse position coordinate to variable and use of variable on a global scale

I'm trying to save the mouse's x and y coordinates when the mouse button is pressed and, separately, when it is released. I am able to print them but unable to save them to variables. Here's what I got: from pynput.mouse import Listener def…
2
votes
1 answer

Using Python (Pygame, Pynput or something else) to write serial data to Arduino to control servos

First, I am very new to Python, but I am trying to write a Python program to write serial data to my Arduino for the purpose to control servos. I am basically wanting my computer’s keyboard to act as a controller for the servos. The process would go…
Skrantzy
  • 21
  • 2
2
votes
1 answer

How to get screen coordinates from color detection resultant area obtained from openCV with python?

I am trying to work with a pen having green cap tip to navigate mouse cursor using webcam but how can I get the coordinates of cap image on screen so that I can give it as input to pyinput library move function. Thanks in advance. # Python program…
DARK_C0D3R
  • 2,075
  • 16
  • 21
1
vote
1 answer

pynput: getting different outputs with pynput.keyboard.Listener.running (in "non-blocking fashion")

In the "non-blocking fashion" of starting a pynput Listener, I'm getting different behaviors with the code below: from time import sleep import pynput def stop(k): if k: print("end") l.stop() l =…
101is5
  • 309
  • 2
  • 12
1
vote
0 answers

Why is Pynput not working in fedora linux?

I am new to pynput and I'm running a basic script to test some functions out: from pynput import keyboard def on_key_press(key): try: print(f'Key pressed: {key.char}') except AttributeError: print(f'Special key pressed:…
1
vote
0 answers

Why thread make my function running slower?

I'm currently coding a macro software where it records mouse movement, click and keyboard input. I'm using Tkinter for the GUI and pynput to detect input. So, in my gui I have two buttons, one for playing the record and one to record mouse and…
LOUDO
  • 19
  • 2
1
vote
1 answer

How do I make pynput ignore letter keys when they are in a combination?

I am trying to make a program for Discord, where you can write with reactions, and it works like this: when the key is pressed, it first deletes it, copies +:regional_indicator_(that letter):, which is the syntax used by Discord for a reaction, to…
Vladutzu27
  • 55
  • 9
1
vote
2 answers

pynput library not working as expected in Python to press Windows + D key

I'm trying to do what this question asked (this question has no valid answers with functional code using pynput): Press Windows+D with pynput. But, my attempts are not working as expected. On Linux Ubuntu, pressing Windows + d will minimize all…
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
1
vote
1 answer

How to stop pynput mouse click from triggering on_click function twice

Currently, I am attempting to write a program that takes a screenshot on mouse-click. The basic functionality works as expected, but, it seems that Pynput is sending two triggers for every one click? (I am getting two screenshots created for every…
1
vote
0 answers

Why logging.txt file is not being created?

I am writing a Keylogger in python and I need that when the variable keydata == "example@hotmail.com" match, a file is created where it will store the words after the verified keydata variable until 3 key.enters are done. Everything works correctly…
Token
  • 11
  • 1
1
vote
2 answers

Pynput breaks the terminal in linux when trying to get key pressed

I have writing the following code to get key pressed by the user: class Key: def __init__(self) -> None: pass # Define the function that will be called when a key is pressed. def on_press(self, key: KeyType) -> None: …
YamiAtem
  • 132
  • 1
  • 9