This script in an Automator Dictation command seems to work.
Not the fullscreen will not work properly if run in Automator or Script editor. It picks up the previous window 1.
But any time I got the Dictation command to work. ( always find a bit of a pain to get them to understand me) It got the right window 100%.
This script uses system profiler to get the monitors. and a bit of simple jiggery to use the width of monitor 1 to determine where bounds are of monitor two.
I did it this way because you may choose not to use fullscreen
I have also tried to make the script accessible to people with one monitor
set theScreens to paragraphs of (do shell script "system_profiler SPDisplaysDataType -detailLevel |grep \"Resolution:\" | awk -F\"Resolution: \" '{print $2}'")
set theMonitor to ""
set the counter to count of theScreens --- set to 1 if you want to test it on monitor 1
if (counter) > 1 then
-- we will do things for monitor 2
set thisDisplayWidthHeightMonitor_2 to {(word 1 of item 1 of theScreens) + 2, 0, ((word 1 of item 1 of theScreens) + (word 1 of item 2 of theScreens)), word 3 of item 2 of theScreens}
set theMonitor to thisDisplayWidthHeightMonitor_2
else
-- we will do things for monitor 1
set thisDisplayWidthHeightMonitor_1 to {0, 0, (word 1 of item 1 of theScreens), (word 3 of item 1 of theScreens)}
set theMonitor to thisDisplayWidthHeightMonitor_1
end if
tell application "Safari"
activate
make new document with properties {URL:"http://netflix.com", index:1}
set bounds of window 1 to theMonitor
end tell
tell application "System Events"
tell application process "Safari"
set value of attribute "AXFullScreen" of window 1 to true
end tell
end tell
Best Answer
The following works on currently latest macOS I'm using (High Sierra 10.13.5 Beta) and latest iTunes (12.7.4.76).
I've written an AppleScript that is using UI Scripting and compiles a list of purchased songs on iTunes. The script will open a new TextEdit document and fill in the songs in a comma delimited format and will contain the sequential number, song name, artist, album and song duration. The output will be similar to this:
Here is the script:
The process is not fast, on my computer it takes about 1 second per song so be prepared to wait a while. Also, if you start getting some "out of index" errors try, while the script is running, scrolling the iTunes song list in the background to make sure the entire list content is loaded before being accessed by AppleScript.