690 questions
7
votes
2
answers
202
views
How can I control an autoclicker without emulated clicks turning it back off?
I want to make an autoclicker that can toggle on and off using = only activates the autoclicker if I hold the left mouse button.
However, the emulated clicks using pynput are being detected as me ...
0
votes
1
answer
69
views
How can I make an autoclicker start on a physical mouse press and stop on release, when its simulated events override the real button state?
I want to create an autoclicker with the following requirements:
Support for left and right mouse buttons: the autoclicker starts as soon as the corresponding mouse button is pressed.
Remains active ...
0
votes
1
answer
94
views
How to get global mouse coordinates in python without using PyautoGUI (Windows and Wayland/Fedora)
I'm looking for a way of retrieving the current X+Y coordinates of the mouse cursor in python without using the PyAutoGUI library. pyautogui.position() works, but I want to avoid dependencies like ...
0
votes
1
answer
63
views
python 3 - pynput window click listener - relative coordinates
I'm trying to write a click bot that can read and write (record). So I need a click listener.
Since pyautogui doesnt have a click listener, I'm using pynput. But pynput only returns the X,Y click for ...
1
vote
0
answers
72
views
How to use Pynput to detect clicks in an iframe on a touch interface?
I've got a webapp with an iframe embedded in it, and have been using pynput as a way to detect the mouse inputs on this webapp. Trouble is, when using the touchscreen to click on the iframe it no ...
-2
votes
1
answer
164
views
python 3 - win32api.PostMessage click on minimized window
I'm trying to click a windows application window while its in a minimized state (don't maximize).
The following code is able to take a snapshot image of a minimized application, then perform image ...
0
votes
1
answer
80
views
Monitor keyboard while a game is running
How to monitor keyboard input while GTA5 is running using python script.
I want to press a key while the game is running to directly terminate the game process.I’ve tried using the keyboard and pynput ...
2
votes
1
answer
61
views
Python - Pynput & the time module do not seem to work together in a loop
So I have written this Python script to vote repeatedly (It's allowed) for a friend on a show at a local TV station.
import os
import time
from pynput.keyboard import Key, Controller
os.system("...
0
votes
0
answers
98
views
Pynput on raspberry pi 4 is not receiving keystrokes
I am trying to get pynput working on my raspberry pi 4. I tried using the example "monitoring keyboard" script from pynput and I am getting exactly the same issue as in this post. I am using ...
0
votes
1
answer
1k
views
how to install keyboard module python 3.12.3 on linux mint
so when ever I try to import the keyboard module in the terminal I tipe:
pip3 install keyboard
and I get a really long error message:
× This environment is externally managed
╰─> To install Python ...
1
vote
0
answers
245
views
Why is pynput not detecting key presses on my Linux machine?
I’m trying to use the pynput library to capture key presses and releases in Python, but the listener is not responding to key events as expected. I’m running the script in a virtual environment on ...
0
votes
0
answers
118
views
Python Keylogger Not Logging Keystrokes on Windows 11, Potential issues with Decrypting logs
I'm developing a Python-based keylogger. The script runs without errors but does not show captured keystrokes on Windows 11. I expected it to log keystrokes in a file, but during the decryption phase ...
0
votes
1
answer
193
views
How to install PyNput on Replit
The problem I'm having is that I can't add the PyNput module to my environment in Replit.
I'm getting this error when I click "install":
warning: no previously-included files found matching '...
0
votes
0
answers
104
views
Python pynput Listener doesn't have permissions
import pynput
import time
def _flush_input():
try:
import msvcrt
while msvcrt.kbhit():
msvcrt.getch()
except ImportError:
import sys, termios
...
0
votes
0
answers
116
views
Trying to make a ghost of whatever is in my clipboard appear where my text cursor is
I am making a program that can store a clipboard history that you can scroll through to choose what to paste. I want some ghost text to appear (where your text cursor is) of what you currently have in ...
0
votes
1
answer
182
views
NotImplementedError when using threading with a keyboard and mouse listener with pynput
Here is the keyboard and mouse listener part of my code:
python
def mouse_listener(scroller):
"""Listens for mouse scroll events to scroll clipboard history."""
...
0
votes
1
answer
61
views
Pynput not logging alphanumerical keys on Mac
I want to detect when I press the "space" bar key using python and pynput.
I tried their documentation, my old code but nothing works anymore on MacOS 15.1.1. Even running the script using ...
0
votes
0
answers
51
views
What key or combination is <71> in pynput library
I had a <71> in pynput keyboard .txt file made but I do not know what pressed. I know that by pressing some keys like the numpad it takes numbers between <> but <71> is unknown for ...
3
votes
1
answer
658
views
Python Unhandled exception in listener callback
I try to get this example code for pynput working:
from pynput import keyboard
def on_activate_h():
print('<ctrl>+<alt>+h pressed')
def on_activate_i():
print('<ctrl>+<...
3
votes
1
answer
432
views
pynput mouse listener is not working on python 3.13.0
I am trying to get mouse click event from the listener of the pynput package, but it's not working.
def init_listeners(self):
try:
self.mouse_listener = mouse.Listener(
on_move=...
0
votes
0
answers
97
views
Python application not opening with Tkinter on Mac OS
I'm new to the mac environment and have never had issues loading tkinter apps on a windows computer. Working on a new basic script to just automate filling out a google form for the sake of my sanity ...
0
votes
2
answers
93
views
Execute code all the time while mouse button is held
Is there any way to execute python code only while the right mouse button is held? If the button becomes up, the code should interrupt immediately.
I tried to use the pynput library but the pressed ...
0
votes
0
answers
139
views
ModuleNotFoundError: No module named 'pynput' after using PyInstaller
I used the keyboard listener from the pynput.keyboard library and when I import it to my project: it works. When I run it to PyInstaller it gives me an error like this:
Traceback (most recent call ...
0
votes
1
answer
70
views
Move between floors
I'm trying to make a sort of nethack inspired type game and I'm trying to figure out the moving up and down(I know the current code is probably terribly inefficient)(also sorry if this question is ...
0
votes
1
answer
147
views
Changing Terminal font size using script?
I am currently making a terminal app, and wanted to allow user to change zoom of a windows 11 terminal. Is there a way to change Font size or any other way?
As I didn't find anything to do it, and I ...
0
votes
1
answer
87
views
Pynput doesn't work when terminal is not in focus
I'm trying to make an app that send keyboard commands to my computer. I have a server running on my computer that receives messages from the app and simulate keystrokes.
The problem is that the ...
0
votes
0
answers
35
views
Input scanning and deletion in real time for pattern recognition
I am using a library called pynput for scanning the keyboard input in real time. I store each character in a list, compress it to a string and detect patterns.
The issue lies in deletion. The scanning ...
0
votes
1
answer
834
views
How do I install a python module for use in a Raycast command script?
On MacOS I'm using the Raycast application launcher which lets you write command scripts to be executed from the raycast menu or a shortcut key.
I wrote a short python script to send simple keyboard ...
0
votes
0
answers
45
views
How to get the input cursor x,y position without mouse-click?
I want to check the keyboard input cursor position [x, y] but I can only get the mouse cursor position, that means you have to mouse-click into the field position to get the cursor position. Is there ...
0
votes
2
answers
59
views
Elif condition that is intended to break the function when it reaches a certain value doesn't work
i have been working on a program that detects the number of times "enter" has been pressed, the problem is that the elif/if condition that is supposed to break the function when the variable ...
0
votes
0
answers
45
views
how to capture user's text input with python modules
i am working on a project where it detects where if you press "(" it closes it automatically
the same thing for "[" and "{"
but the point is it detects the keyboard ...
-1
votes
1
answer
201
views
Pynput for testing if ctrl, shift or alt are pressed
Is there a way in Pynput to test if ctrl, shift or alt are pressed in the òn_pressed or on_release handler?
0
votes
0
answers
61
views
Click is not being executed at end_time
So I have a Python script which I have been working on for some time and I am coming across a small issue and I can't seem to figure it out.
So for a small debrief, this basically what the ...
0
votes
1
answer
66
views
Stop a Program from Running using a Character Without pressing Enter key in Python 3.x
I have tried some solutions that I could get from the other threads here but still no luck. My issue is that the program can recognize the character I've entered but does not execute to stop the ...
1
vote
0
answers
124
views
Python pynput not working as expected on osx
I'm trying to catch keystrokes in a python script, but it ONLY catches modifier keys (ctrl, cmd, alt) and not ordinary alphanumerical keys. Running on Mac Sonoma 14.1.1, Python 3.10.6.
from pynput....
1
vote
1
answer
165
views
python pynput how to listen to a hotkey and single key simultaneously?
I have a hotkey set up with pynput:
hotkey = keyboard.HotKey(
keyboard.HotKey.parse('<alt>+b'),
on_activate=on_activate
)
# Function to handle canonical form for key events
def ...
0
votes
1
answer
34
views
how do i make it so it only types one key in pynput
i dont know how do i make it if ex. x axis is 254 and y axis is 254 it should only type one r and not spam r, i really dont know how i can fix it , someone please help
import pygame
import time
import ...
1
vote
1
answer
52
views
python add a hotkey but stop the keypresses from passing through to other apps
Let's say I want a python program to bind to Shift+f. If you open up notepad and in there press Shift+f, then a capital F will appear. This means notepad received the keypresses. If you instead press ...
0
votes
0
answers
86
views
Problem in python with pynput.keyboard module
I work with Anaconda and Spyder.
I have a Python code that does some web scraping, and it worked fine until I updated Anaconda and Spyder a few days ago.
I'm having trouble with simulating writing or ...
0
votes
0
answers
229
views
Pynput not recognizing inputs when terminal is focused
I'm on Ubuntu 24, using Python 3.12. I have a basic Python script with pynput that stops the program execution when the up arrow is pressed. Running this script in Pycharm has no problems, but in a ...
1
vote
2
answers
305
views
Issues with threading and hotkeys using pynput in Python (Infinite Loop and Responsiveness)
I'm trying to use the pynput library to listen for hotkeys and start a thread when the F12 key is pressed. The thread prints a message in an infinite loop to the console. Pressing ESC should stop the ...
0
votes
0
answers
107
views
Pynput mouse.move() function does not stop when it reaches edge of screen
When I'm using the mouse.move() function with the Pynput package, the mouse does not stop moving when it reaches the edge of the screen. For example with the following code:
from pynput.mouse import ...
2
votes
4
answers
1k
views
How can I read raw mouse input with Python?
I know that PyAutoGUI and Pynput can read mouse inputs, but they can only read your coordinates on the screen. I'm trying to create a macro recorder but I need to be able to read the input being ...
1
vote
0
answers
97
views
Unable to detect mouse movement with pynput mouse listener when run as a service
I am trying to create a windows service using python that monitors mouse movement and keyboard presses. The code works fine when ran in the console however when I modified it to turn it into a service,...
0
votes
2
answers
63
views
Python cannot write mouse coordinates to self.label in a different function in the same class. Why is that function not recognising that label?
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# GUI module generated by PAGE version 8.0
# in conjunction with Tcl version 8.6
# Apr 23, 2024 11:05:03 PM CEST platform: Windows NT
import sys
...
0
votes
1
answer
67
views
Prevent specific key presses from being sent to foreground app using PyQt5 and pynput
So I want to detect certain keys being pressed and stop those keys being sent to the foreground app.
I don't want to use hideous libraries like pywin32 and pyHook as they are such a headache to build. ...
0
votes
0
answers
38
views
Refactoring Python Code for Mouse and Keyboard Actions with Pynput
I have a script that uses the pynput library to perform a series of mouse and keyboard actions. The script highlights certain areas on the screen, copies the highlighted content, and saves it to ...
0
votes
0
answers
34
views
im trying to use pynput to press enter but its not registering, ive looked around quite a bit and i cant see anyone else having this problem
im writing a program that writes a program (my coding skill sucks dont worry about it) and when i run this line:
keyboard.press(Key.enter) it doesnt work at all (its also not returning any errors so ...
0
votes
0
answers
304
views
Python pynput doesn't work correct when Windows choosen language doesn't contain appropriate char
i am trying to simulate keyboard input using pynput.keyboard Controller
for example, here is a function that is supposed to minimize all windows
from pynput.keyboard import Controller as ...
1
vote
0
answers
162
views
Pynput keyboard listener is working only when the terminals are minimised
I am using the following code to read keyboard events using pynput and publish a suitable msg in ROS2.
import rclpy
from my_interfaces.msg import Chassis
import threading
import time
from pynput ...