Skip to content

Instantly share code, notes, and snippets.

Created August 8, 2012 13:16
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 anonymous/3294970 to your computer and use it in GitHub Desktop.
Save anonymous/3294970 to your computer and use it in GitHub Desktop.
Google's basketball doodle playing with Python
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