Advertisement
Rnery

Press key "J" every 1 second..

Jan 5th, 2024
1,069
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | Source Code | 1 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. from time import sleep
  5. from pyautogui import press
  6.  
  7. class KeyPresser:
  8.     def __init__(self, key='j', interval=1):
  9.         self.key = key
  10.         self.interval = interval
  11.  
  12.     def press_key(self):
  13.         press(self.key)
  14.  
  15.     def run(self):
  16.         while True:
  17.             self.press_key()
  18.             sleep(self.interval)
  19.  
  20. if __name__ == "__main__":
  21.     key_presser = KeyPresser()
  22.     key_presser.run()
  23.  
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement