Skip to content

Instantly share code, notes, and snippets.

@dpb587
Created January 28, 2013 23:04
Show Gist options
  • Save dpb587/4660132 to your computer and use it in GitHub Desktop.
Save dpb587/4660132 to your computer and use it in GitHub Desktop.
Scripting Endicia to Purchase Postage - automating user interactions with AppleScript.

Details

Related blog post: dpb587.me/blog/blog/2013/01/28/scripting-endicia-to-purchase-postage.html

License

MIT License (http://opensource.org/licenses/mit-license.php)

Copyright (c) 2013 Danny Berger <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
on run argv
tell application "System Events"
if UI elements enabled is false then
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.universalaccess"
display dialog "This feature cannot be used until \"Enable access for assistive devices\" is enabled here. Please make that change and then try again." with icon 1 buttons {"OK"} default button "OK"
return "error"
end tell
end if
end tell
tell application "Endicia"
activate
tell application "System Events" to tell application process "Endicia"
tell menu bar 1
tell menu bar item "Postage"
pick
tell menu 1
pick menu item "Buy Postage…"
end tell
end tell
end tell
delay 1
tell window "Buy Postage"
tell pop up button 1
click
tell menu 1
click menu item ("$" & (item 1 of argv) & ".00")
end tell
end tell
tell button "Purchase Postage Now"
click
end tell
end tell
delay 1
tell window 1
tell button "OK"
click
end tell
end tell
return "ok"
end tell
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment