Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
62 lines (51 loc) · 6.74 KB

hs.osascript.md

File metadata and controls

62 lines (51 loc) · 6.74 KB

docs » hs.osascript


Execute Open Scripting Architecture (OSA) code - AppleScript and JavaScript

API Overview

API Documentation

Functions

Signature hs.osascript._osascript(source, language) -> bool, object, descriptor
Type Function
Description Runs osascript code
Parameters
  • source - Some osascript code to execute
  • language - A string containing the OSA language, either 'AppleScript' or 'JavaScript'. Defaults to AppleScript if invalid language
Returns
  • A boolean value indicating whether the code succeeded or not
  • An object containing the parsed output that can be any type, or nil if unsuccessful
  • A string containing the raw output of the code and/or its errors
Signature hs.osascript.applescript(source) -> bool, object, descriptor
Type Function
Description Runs AppleScript code
Parameters
  • source - A string containing some AppleScript code to execute
Returns
  • A boolean value indicating whether the code succeeded or not
  • An object containing the parsed output that can be any type, or nil if unsuccessful
  • If the code succeeded, the raw output of the code string. If the code failed, a table containing an error dictionary
Notes
  • Use hs.osascript._osascript(source, "AppleScript") if you always want the result as a string, even when a failure occurs
Signature hs.osascript.applescriptFromFile(fileName) -> bool, object, descriptor
Type Function
Description Runs AppleScript code from a source file.
Parameters
  • fileName - A string containing the file name of an AppleScript file to execute.
Returns
  • A boolean value indicating whether the code succeeded or not
  • An object containing the parsed output that can be any type, or nil if unsuccessful
  • If the code succeeded, the raw output of the code string. If the code failed, a table containing an error dictionary
Notes
  • This function uses hs.osascript.applescript for execution.
  • Use hs.osascript._osascript(source, "AppleScript") if you always want the result as a string, even when a failure occurs. However, this function can only take a string, and not a file name.
Signature hs.osascript.javascript(source) -> bool, object, descriptor
Type Function
Description Runs JavaScript code
Parameters
  • source - A string containing some JavaScript code to execute
Returns
  • A boolean value indicating whether the code succeeded or not
  • An object containing the parsed output that can be any type, or nil if unsuccessful
  • If the code succeeded, the raw output of the code string. If the code failed, a table containing an error dictionary
Notes
  • Use hs.osascript._osascript(source, "JavaScript") if you always want the result as a string, even when a failure occurs
Signature hs.osascript.javascriptFromFile(fileName) -> bool, object, descriptor
Type Function
Description Runs JavaScript code from a source file.
Parameters
  • fileName - A string containing the file name of an JavaScript file to execute.
Returns
  • A boolean value indicating whether the code succeeded or not
  • An object containing the parsed output that can be any type, or nil if unsuccessful
  • If the code succeeded, the raw output of the code string. If the code failed, a table containing an error dictionary
Notes
  • This function uses hs.osascript.javascript for execution.
  • Use hs.osascript._osascript(source, "JavaScript") if you always want the result as a string, even when a failure occurs. However, this function can only take a string, and not a file name.