Created
August 8, 2012 04:00
-
-
Save rivert/3291935 to your computer and use it in GitHub Desktop.
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
# 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