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 to trigger mouse clicks only when a key is pressed ? In Python

I want to make a program or when I click on a key the mouse clicks automatically (as long as I click on the key) if I do not click on the key it stops. I don't want the clicks to happen only when I touch the key once, but as long as the key is held…
jush456
  • 51
  • 5
2
votes
0 answers

Pynput mouse listener freezing input

I am making a program that toggles on and off by a holding a certain mouse button(using pynput). The problem is that after I start the code and hold the mouse button, while the class is being executed, there is lag in the movement of the cursor. How…
2
votes
0 answers

File framework is not there

I want to try the pynput module, but it failed to work not giving me an error. I try to find the pynput module and when I pip install my terminal says that it is in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages.…
2
votes
0 answers

Packages Pynput and Pyautogui not working

I'm trying to automate some stuff on my Mac OS Big Sur 11.5.2 . I used to do it on my old computer that was running High Sierra. Now both the packages pyautogui and pynput can run but they never execute the commands that they're supposed to. It's…
2
votes
0 answers

How to capture additional keystrokes after a particular keystroke event using pynput

Hello I'm mainly trying to find out if the current way I'm going about this small project idea makes sense because my idea is sort of in-between a few different ideas. I would describe it as an active profanity filter that is meant to alert the…
2
votes
1 answer

Is it possible to hold down mouse button for certain time using pynput?

I know there are similar questions, but those are about the Keyboard Controller and I need the mouse Controller. So I have a program, where I need to hold down lmb for a certain amount of time. I've tried…
2
votes
1 answer

Simultaneous mouse press events in Python using Pynput

I am using scrcpy to mirror an Android phone to my computer in order to play a game. The issue is that scrcpy does not support keyboard mapping natively, so I'm writing a Python script to map the keyboard to execute the key presses I need to play…
2
votes
3 answers

Error raised while installing pynput in termux

I'm trying to install pynput in Termux to be able to run my python script. When I try [as in the attached screenshot] pip install pynput I get this error message: ERROR: Command errored out with exit status 1: command:…
rey_track
  • 31
  • 3
2
votes
1 answer

Cursor not moving to originial spot pynput

My current code looks like this: from pynput.mouse import Button, Controller, Listener mouse = Controller() def on_click(x, y, button, pressed): if button == Button.right: placeX = x placeY = y mouse.position = (placeX,…
NewUser
  • 23
  • 5
2
votes
1 answer

Stopping running while loop if conditions are met

The code below is intended to print out the contents of arrays, until either the mouse (left click) is released, or the end of the array is reached. How would I stop the while loop in the function logging_mouse, once the mouse is released? running =…
2
votes
1 answer

Block mouse click in Python

I am working on a little Mouse Spamming Stopper script in Python and I don't really know how can I only block the mouse click, but still be able to move the mouse. This is what I got so far: from pynput.mouse import Listener import…
VIc Pitic
  • 21
  • 3
2
votes
0 answers

How to fix pynput installation error on pop os?

I had a freash installation of pop os, installed pip and I updated everything usig the following command sudo apt update sudo apt upgrade now I want to install the pynput module so I tried the following command pip install pynput But I got the…
itsmmdoha
  • 21
  • 1
2
votes
2 answers

Monitoring mouse coordinate while a key is pressed

I am trying to make a windows analog of the Chat-wheel from Dota 2 or Battlefield with some fast commands like this. How it should be: While the G-key is pressed - the wheel with some sections appears at the centre of the screen, with the mouse…
LogaN4ik
  • 71
  • 8
2
votes
1 answer

Detecting both mouse buttons held down

I am new to python and I found a code that detects mouse buttons when held down and released, but i want "x" to turn True when both of the buttons held down, how can I do this # This function will be called when any key of mouse is pressed def…
2
votes
2 answers

How can i detect CTRL+C in python3.8?

I have this program in pycharm python3.8 that i need to detect if ctrl+c is pressed anywhere while browsing windows while the program is running, but for some reason the program does not detect if the pressed key is the "ctrl" my code looks like…
Ptmlol
  • 37
  • 2
  • 6