This is my code:
import time
import pyautogui
import keyboard
# Get initial mouse position
initial_x, initial_y = pyautogui.position()
while not keyboard.is_pressed("esc"):
# Click at the initial mouse position
pyautogui.click(x=initial_x, y=initial_y)
time.sleep(0.1) # Adjust the delay between clicks if needed
print("Stopped clicking (Esc key pressed).")
This is the error:
/home/Gavin/.local/lib/python3.11/site-packages/keyboard/_nixkeyboard.py:110: UserWarning: Failed to create a device file using `uinput` module. Sending of events may be limited or unavailable depending on plugged-in devices.
device = aggregate_devices('kbd')
Couldn't get a file descriptor referring to the console.
Traceback (most recent call last):
File "/home/Gavin/Downloads/spamclick.py", line 8, in <module>
while not keyboard.is_pressed("esc"):
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/__init__.py", line 410, in is_pressed
_listener.start_if_necessary()
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
self.init()
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/__init__.py", line 196, in init
_os_keyboard.init()
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/_nixkeyboard.py", line 114, in init
build_tables()
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/_nixkeyboard.py", line 73, in build_tables
dump = check_output(['dumpkeys', '--keys-only'], universal_newlines=True)
File "/usr/lib/python3.11/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['dumpkeys', '--keys-only']' returned non-zero exit status 1.
import time
import pyautogui
import keyboard
# Get initial mouse position
initial_x, initial_y = pyautogui.position()
while not keyboard.is_pressed("esc"):
# Click at the initial mouse position
pyautogui.click(x=initial_x, y=initial_y)
time.sleep(0.1) # Adjust the delay between clicks if needed
print("Stopped clicking (Esc key pressed).")
This is the error:
/home/Gavin/.local/lib/python3.11/site-packages/keyboard/_nixkeyboard.py:110: UserWarning: Failed to create a device file using `uinput` module. Sending of events may be limited or unavailable depending on plugged-in devices.
device = aggregate_devices('kbd')
Couldn't get a file descriptor referring to the console.
Traceback (most recent call last):
File "/home/Gavin/Downloads/spamclick.py", line 8, in <module>
while not keyboard.is_pressed("esc"):
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/__init__.py", line 410, in is_pressed
_listener.start_if_necessary()
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
self.init()
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/__init__.py", line 196, in init
_os_keyboard.init()
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/_nixkeyboard.py", line 114, in init
build_tables()
File "/home/Gavin/.local/lib/python3.11/site-packages/keyboard/_nixkeyboard.py", line 73, in build_tables
dump = check_output(['dumpkeys', '--keys-only'], universal_newlines=True)
File "/usr/lib/python3.11/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['dumpkeys', '--keys-only']' returned non-zero exit status 1.
Statistics: Posted by PYTHON IS FUN — Wed May 15, 2024 9:13 pm