Last active
March 26, 2020 00:18
-
-
Save engividal/91c9b0883dad24ce4f6bd741d01c5a1b to your computer and use it in GitHub Desktop.
I use this gist when need to maintain the connection on google codelab for a long time. Is necessary to install the library pynput(https://pypi.org/project/pynput/) and run in Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Spyder Editor | |
Maintain the connection on google codelab google for a long time. write in google cell at random time between 1 and 100 seconds. | |
""" | |
from pynput.keyboard import Key, Controller | |
import time | |
import random | |
keyboard = Controller() | |
with keyboard.pressed(Key.alt): | |
keyboard.press(Key.tab) | |
keyboard.release(Key.tab) | |
while True: | |
i = random.randint(1,100) | |
print(i) | |
keyboard.type(str(i)) | |
time.sleep(i) | |
with keyboard.pressed(Key.ctrl): | |
keyboard.press('a') | |
keyboard.release('a') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment