Skip to content

Instantly share code, notes, and snippets.

@demus
Created July 4, 2016 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save demus/201e5230c86bd1558614094d597a4363 to your computer and use it in GitHub Desktop.
Save demus/201e5230c86bd1558614094d597a4363 to your computer and use it in GitHub Desktop.
Simple auto putt script for steam game Golf With Your Friends: http://store.steampowered.com/app/431240/
import ctypes
import time
# DWORDS
MOUSEEVENTF_MOVE = 0x00000001
MOUSEEVENTF_LEFTDOWN = 0x00000002
MOUSEEVENTF_LEFTUP = 0x00000004
# initialize user32 dll wrapper
user32 = ctypes.windll.user32
SCREEN_WIDTH = user32.GetSystemMetrics(0)
SCREEN_HEIGHT = user32.GetSystemMetrics(1)
# set duration of script
duration = 60*15
def putt(x, y):
user32.SetCursorPos(x, y)
user32.mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
user32.mouse_event(MOUSEEVENTF_MOVE, 0, -1)
user32.mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def main():
timeout = time.time() + duration
while True:
time.sleep(0.5)
if time.time() > timeout:
break
putt(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment