Created
April 28, 2013 04:43
-
-
Save cbess/5475915 to your computer and use it in GitHub Desktop.
Uses python AppleScript to inject cheat codes in Boxer for Mac
This file contains hidden or 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
# This script will enable cheats within Constructor (via Boxer) | |
# created by C. Bess - 10/14/2012 | |
# | |
# - Exec the script while at the player select screen, then in the game press 'C', | |
# "+" symbol will be shown next to the date when activated. | |
# | |
# * = favs | |
# | |
# cheats: | |
# Faster network game - speed471 | |
# * Buy worker at any time - worker902 | |
# Convert worker into gangster at any time - gangster822 | |
# Buy any gangster weapon - weapons473 | |
# Select any tenant at any time - tenants127 | |
# Build any fence at any time - fences673 | |
# * Borrow any amount of money from bank - loans039 | |
# Buy any estate without limits - estates131 | |
# Select any house at any time - houses738 | |
# Press [Ctrl] when placing house for instant building - build909 | |
# Use any undesirable action on easy level - actions674 | |
# Build any gadget - gadgets337 | |
# * Press [Alt] + I to toggle missions - missions824 | |
# * Press [Alt] + C to toggle complaints - complain840 | |
# Press [Alt] + P for police cadets, [Alt] + M for mob bribes - cadets552 | |
# Switch teams in single player mode - teams418 | |
# Play any map with any number of players - maps751 | |
from appscript import * | |
import re | |
import time | |
regex_digits = re.compile(r'\d+$') | |
regex_word = re.compile('[a-z]+') | |
# returns the hardware keycode for the specified number | |
hw_keycode = lambda kc: {0: 29, 1: 18, 2: 19, 3: 20, 4: 21, 5: 23, 6: 22, 7: 26, 8: 28, 9: 25}[kc] | |
sevents = app('System Events') | |
# target_app = app('TextEdit') | |
target_app = app('Boxer') | |
target_app.activate() | |
print 'Activate the app (click inside the window)' | |
time.sleep(3) | |
# the cheat keystrokes | |
cheat_keystrokes = [ | |
'worker902', | |
'loans039', | |
'missions824', | |
'complain840', | |
'tenants127', | |
'cadets552', | |
'weapons473' | |
] | |
for ks in cheat_keystrokes: | |
print 'Entering: %s' % ks | |
wait = 0.1 # time to wait in-between each key press | |
time.sleep(wait) # must delay, wait for it to be processed | |
# send the word as normal keystrokes | |
word = regex_word.match(ks).group() | |
for char in word: | |
time.sleep(wait) | |
sevents.keystroke(char) | |
# grab the numbers to generate the hardware keycodes for each number | |
numbers = regex_digits.search(ks).group(0) | |
for num in numbers: | |
time.sleep(wait) | |
key = int(hw_keycode(int(num))) | |
# send the keycodes | |
sevents.key_code(key) | |
time.sleep(wait) # wait | |
sevents.key_code(36) # [enter] key (ex?: 52, 36, 13) | |
time.sleep(1) | |
print 'Done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment