Last active
December 17, 2020 21:10
-
-
Save uchcode/f6c163e62a6548f8fc93 to your computer and use it in GitHub Desktop.
calling osascript from ruby
This file contains 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
require "open3" | |
def osascript language, script | |
Open3.capture3 "osascript", *["-l", language, :stdin_data => script] | |
end | |
def applescript script | |
osascript "AppleScript", script | |
end | |
def jxascript script | |
osascript "JavaScript", script | |
end | |
p applescript <<-END | |
display alert 1+1 | |
END | |
p jxascript <<-END | |
App = Application.currentApplication() | |
App.includeStandardAdditions = true | |
App.displayAlert(1+1) | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment