Skip to content

Instantly share code, notes, and snippets.

@rivert
Created August 8, 2012 04:00
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 rivert/3291935 to your computer and use it in GitHub Desktop.
Save rivert/3291935 to your computer and use it in GitHub Desktop.
# needs python-pyatspi (apt-get install python-pyatspi)
# open http://www.google.com/doodles/basketball-2012
# start script, head over to the browser, click play (or retry), the script kicks in after 5sec
# /bw
import time
import pyatspi
VK_CODE = {'left_arrow':113,
'right_arrow':114,
'spacebar':65 }
def press(x):
pyatspi.Registry.generateKeyboardEvent(VK_CODE[x], None, pyatspi.KEY_PRESS)
def release(x):
pyatspi.Registry.generateKeyboardEvent(VK_CODE[x], None, pyatspi.KEY_RELEASE)
def play():
cnt = 0
base= 0.37
time.sleep(5)
s = time.time()
while time.time() - s < 25:
# print cnt, base
press("spacebar")
time.sleep(base)
release("spacebar")
cnt += 1
if cnt == 14:
base += 0.27
if cnt == 22:
base += 0.12
if cnt == 30:
base += 0.1
if cnt == 38:
base += 0.4
play()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment