Skip to content

Instantly share code, notes, and snippets.

@dceoy
Created May 22, 2023 06:49
Show Gist options
  • Save dceoy/1a877a4d6f16d77f09741e3fdc8282eb to your computer and use it in GitHub Desktop.
Save dceoy/1a877a4d6f16d77f09741e3fdc8282eb to your computer and use it in GitHub Desktop.
[Python] Press a key using PyAutoGUI
#!/usr/bin/env python
import signal
import time
import pyautogui
def press_esc_repeatedly(waiting_sec=300, pressed_key='esc'):
signal.signal(signal.SIGINT, signal.SIG_DFL)
while True:
pyautogui.press(pressed_key)
time.sleep(waiting_sec)
if __name__ == '__main__':
press_esc_repeatedly()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment