Created
March 20, 2015 02:40
-
-
Save brettcvz/2c73176e49e079ab3d3e to your computer and use it in GitHub Desktop.
Revisions
-
brettcvz created this gist
Mar 20, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/usr/bin/env osascript -l JavaScript function run(argv) { var to = argv[0]; var msg = argv[1]; console.log("Sending message", "'" + msg + "'", "to", to); messages = Application('Messages'); var service; for (var i in messages.services) { var s = messages.services[i]; var name = s.name(); if (name == "SMS") { service = s; console.log("Sending via SMS"); break; } else if (name.substring(0,2) == "E:") { service = s; console.log("Sending via iMessage"); break; } } recip = service.buddies[to]; messages.send(msg, {to: recip}); }