Skip to content

Instantly share code, notes, and snippets.

@engividal
Last active March 26, 2020 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save engividal/91c9b0883dad24ce4f6bd741d01c5a1b to your computer and use it in GitHub Desktop.
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.
# -*- 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