We recently updated our AppleScript/JXA APIs! This means increased and improved macOS application programmatic access to Windows, Tabs, and Spaces within Arc.
While we’ve included a few examples of things that you can now do with the new API below, you can also find the full docs as a Dictionary via the Script Editor
app on any Mac:
🔷 For feedback or questions you can always find us by hitting CMD T > Feedback or send us a note on members.arc.net! We can’t wait to see what you’ll build.
Windows
Querying for open windows
tell application "Arc"
get the title of every window
get the properties of front window
tell front window
/* do something */
end tell
end tell
You can use the every window
, front window
, and window <number>
commands to query for windows.
Opening a new window
tell application "Arc"
make new window -- creates a new window
make new window with properties {incognito:true} -- creates a new incognito window
end tell
To open a new window, you can run the make new window
command in the application
scope.
Opening a URL in Little Arc
tell application "Arc"
make new tab with properties {URL:"<https://arc.net>"}
end tell
To open a new Little Arc window, you can run the make new tab
command in the application
scope.
Spaces
Querying for spaces
tell application "Arc"
tell front window
get the properties of every space
tell space 2
/* do something */
end tell
end tell
end tell
You can query for spaces with the every space
and space <number>
commands within a window
’s scope.
Switching to a space
tell application "Arc"
tell front window
tell space 2 to focus
end tell
end tell
You can also run the focus
command on a space, which switches to that space in that window.
Tabs
Querying for tabs
tell application "Arc"
tell front window
get the properties of every tab
get the properties of active tab
tell space 1
get the properties of every tab
get the properties of tab 9
end tell
end tell
end tell
You can query for tabs with in a window
or space
scope using the active tab
, every tab
, or tab <number>
commands.
Selecting a tab
tell application "Arc"
tell front window
tell tab 2 to select
delay 5
tell space 1
tell tab 9 to select
end tell
end tell
end tell
You can use the select
command on a tab to select it.
Creating a new tab
tell application "Arc"
tell front window
make new tab with properties {URL:"<https://arc.net>"}
delay 5
tell space 1
make new tab with properties {URL:"<https://thebrowser.company>"}
end tell
end tell
end tell
You can also create new tabs within the window
and space
scopes. Note that unlike creating a tab within the application
scope, which opens a Little Arc window, creating a new tab within a window or space will create that tab within that window or space.
Running JS within a tab
tell application "Arc"
tell front window
tell active tab
execute javascript "console.log('Hi from AppleScript!')"
log (execute javascript "(function() { return 'Hi there' })()")
end tell
end tell
end tell
You can also run arbitrary Javascript within a tab using the execute javascript
command. Return values from the javascript string are returned back to AppleScript.