Thanks to you both! For both my original attempt and your suggestions, when I run it the script in Script Editor, I get the result “missing value”. Any further thoughts?
tell application "Orion"
make new document -- maybe this. Creates window
make new tab at end of tabs of window 1 with properties {URL:"https://twitter.com"}
end tell
With some properties of some applications, it’s necessary to make the element first and then set the property value. I don’t know if this is the case here, but it may be worth a try:
tell application "Orion"
set newTab to (make new tab at window 1)
set newTab's URL to "https://twitter.com"
end tell
This works for me. The result, yes, is missing value, but it does create a new tab in the window opened to that URL.
tell application "Orion"
tell window 1
make new tab with properties {URL:"https://twitter.com"}
end tell
end tell
I removed the “at beginning” part because Orion seemed to ignore that and make all new tabs at the end. (a bug)
Also, once you create a new tab, I don’t see a way to address it. There is a current tab property, but that errors; “last tab” errors; “every tab” errors.
Since this is in beta, maybe they will want to fix their AppleScript implementation?
EDIT: Try this…
tell application "Orion"
tell window 1
make new tab with properties {URL:"https://twitter.com"}
set tabcount to number of tabs
set myTab to tab tabcount
tell myTab
set tabName to its name
set tabURL to its URL
end tell
end tell
end tell
I noticed that the Orion app doesn’t forget windows after they’re closed. For example, in my browser there’s only 1 open window, but Orion returns 16 windows from the number of windows command.
These work for me in Mojave — provided the window’s included in the specifiers, of course.
tell application "Orion"
activate
tell window 1
make new tab with properties {URL:"https://macscripter.net"} -- returns missing value, but works.
make new tab with properties {URL:"https://www.bbc.co.uk/news"} -- ditto.
tabs
--> {tab 1 of window id 1820 of application "Orion", tab 2 of window id 1820 of application "Orion", tab 3 of window id 1820 of application "Orion"}
set current tab to last tab -- selects rightmost tab, but returns nothing.
--set current tab to first tab whose URL is "https://macscripter.net" --> errors.
set current tab to first tab whose name is "MacScripter" -- works, but returns nothing. Needs time for the tab to load content and get named.
--set current tab to tab named "MacScripter" -- ditto.
--set current tab to tab "MacScripter" -- ditto..
properties of every tab
--> {{name:"Start Page", class:tab, URL:"orion://newtab/"}, {name:"MacScripter", class:tab, URL:"https://macscripter.net/"}, {name:"Home - BBC News", class:tab, URL:"https://www.bbc.co.uk/news"}}
end tell
end tell
So tabs can be created, opened, and viewed, but there’s currently no way to get their content.
FYI, since Orion is in beta and and I checked out their website and they seem to have an active forum where the developer is interacting with users, and there are a few threads about their appleScript implementation.
I referred the developer here and to ScriptDebugger forums.
This has helped me sort out another wrinkle: Orion’s “named windows” feature (sort of like Safari’s tab groups) means that if you write [format]tell window 1[/format] …then Orion looks for a window that is named “Window 1” rather than using the frontmost window.
I finally got the behavior I was looking for—though still with the “missing value” result—by specifying that I was referring to the window index:
tell application "Orion"
tell window index 1
make new tab with properties {URL:"https://twitter.com"}
end tell
end tell
tell application "Orion"
tell window index 1
make new tab with properties {URL:"https://twitter.com"}
set tabcount to number of tabs
set myTab to tab tabcount
tell myTab
set tabName to its name
end tell
set current tab to first tab whose name is tabName
end tell
end tell
I can’t get this to work with Chinese characters.
This script opens correctly in Safari, but creates a blank tab in Orion.
tell application "Orion"
tell window index 1
make new tab with properties {URL:"https://translate.google.com/?sl=auto&tl=en&text=更是"}
end tell
end tell
You need to replace the Chinese characters in the URL query with percent codes:
use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later
use framework "Foundation"
set chineseText to "更是"
set escapedText to ((current application's NSString's stringWithString:(chineseText))'s ¬
stringByAddingPercentEncodingWithAllowedCharacters:(current application's NSCharacterSet's URLQueryAllowedCharacterSet())) as text
--> "%E6%9B%B4%E6%98%AF"
tell application "Orion"
tell window index 1
make new tab with properties {URL:"https://translate.google.com/?sl=auto&tl=en&text=" & escapedText}
end tell
end tell