Skip to content

Instantly share code, notes, and snippets.

@2shortplanks
Created January 24, 2014 14:24
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 2shortplanks/8598208 to your computer and use it in GitHub Desktop.
Save 2shortplanks/8598208 to your computer and use it in GitHub Desktop.
Example KeyboardMaestro script to play Guess My Number
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>IsActive</key>
<true/>
<key>Macros</key>
<array>
<dict>
<key>Actions</key>
<array>
<dict>
<key>DisplayKind</key>
<string>Variable</string>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>ExecuteShellScript</string>
<key>Path</key>
<string></string>
<key>Text</key>
<string>#!/usr/bin/perl
print int(rand 100)+1</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>TrimResults</key>
<true/>
<key>TrimResultsNew</key>
<true/>
<key>UseText</key>
<true/>
<key>Variable</key>
<string>SecretNumber</string>
</dict>
<dict>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>SetVariableToText</string>
<key>Text</key>
<string>Not yet</string>
<key>Variable</key>
<string>Guess</string>
</dict>
<dict>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>SetVariableToText</string>
<key>Text</key>
<string>This is your first guess</string>
<key>Variable</key>
<string>Feedback</string>
</dict>
<dict>
<key>Actions</key>
<array>
<dict>
<key>Buttons</key>
<array>
<dict>
<key>Button</key>
<string>Guess</string>
<key>Cancel</key>
<false/>
</dict>
<dict>
<key>Button</key>
<string>Give Up</string>
<key>Cancel</key>
<true/>
</dict>
</array>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>PromptForUserInput</string>
<key>Prompt</key>
<string>Guess my number between 1-100. %Variable%Feedback%</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>Title</key>
<string>Guess My Number</string>
<key>Variables</key>
<array>
<dict>
<key>Default</key>
<string></string>
<key>Variable</key>
<string>Guess</string>
</dict>
</array>
</dict>
<dict>
<key>DisplayKind</key>
<string>Variable</string>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>ExecuteShellScript</string>
<key>Path</key>
<string></string>
<key>Text</key>
<string>#!/usr/bin/perl
print "Your last guess was too " . ($ENV{KMVAR_Guess} &lt; $ENV{KMVAR_SecretNumber} ? "low" : "high")
</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>TrimResults</key>
<true/>
<key>TrimResultsNew</key>
<true/>
<key>UseText</key>
<true/>
<key>Variable</key>
<string>Feedback</string>
</dict>
</array>
<key>Conditions</key>
<dict>
<key>ConditionList</key>
<array>
<dict>
<key>ConditionType</key>
<string>Variable</string>
<key>Variable</key>
<string>Guess</string>
<key>VariableConditionType</key>
<string>IsNot</string>
<key>VariableValue</key>
<string>%Variable%SecretNumber%</string>
</dict>
</array>
<key>ConditionListMatch</key>
<string>All</string>
</dict>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>While</string>
<key>TimeOutAbortsMacro</key>
<true/>
</dict>
<dict>
<key>Buttons</key>
<array>
<dict>
<key>Button</key>
<string>Yey!</string>
<key>Cancel</key>
<true/>
</dict>
</array>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>PromptForUserInput</string>
<key>Prompt</key>
<string>Yep, the secret number was %Variable%SecretNumber%</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>Title</key>
<string>You Win!</string>
<key>Variables</key>
<array/>
</dict>
</array>
<key>IsActive</key>
<true/>
<key>ModificationDate</key>
<real>412144980.25019097</real>
<key>Name</key>
<string>Guess My Number</string>
<key>Triggers</key>
<array/>
<key>UID</key>
<string>CC000EE6-7E77-4CF6-A8B8-500B5EDA1AA1</string>
</dict>
</array>
<key>Name</key>
<string>Games</string>
<key>UID</key>
<string>50CC3C66-6E19-4CC0-84B1-6FC06D1C048D</string>
</dict>
</array>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment