Created
August 8, 2012 13:16
-
-
Save anonymous/3294970 to your computer and use it in GitHub Desktop.
Google's basketball doodle playing with 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
import time | |
import win32api, win32con | |
VK_CODE = {'spacebar':0x20} | |
def press_down(x): | |
win32api.keybd_event(VK_CODE[x], 0,0,0) | |
def press_up(x): | |
win32api.keybd_event(VK_CODE[x],0 ,win32con.KEYEVENTF_KEYUP ,0) | |
def play(): | |
time.sleep(2 ) | |
s = time.time() | |
t = 0.6 | |
c = 0 | |
press_down('spacebar') | |
time.sleep( 0.5 ) | |
press_up('spacebar') | |
time.sleep( 0.5 ) | |
while time.time() - s < 25: | |
press_down('spacebar') | |
time.sleep( t ) | |
press_up('spacebar') | |
time.sleep(0.5 ) | |
c +=1 | |
if c == 4 : | |
t = 0.9 | |
if c == 10 : | |
t = 1.1 | |
if c == 16 : | |
t = 1.4 | |
play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment