Skip to content

Instantly share code, notes, and snippets.

@rivert

rivert/gist:3291935

Created Aug 8, 2012
Embed
What would you like to do?
# 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
You can’t perform that action at this time.