Hello and thanks for taking the time to help.
I have limited coding experience in AppleScript. What Im trying to do is create a script that will open, set to fullscreen, and then arrange several applications that I use regularly. I added some logic into the script to help the flow if the applications are already open. but the problem I'm running into is during the For Next Loop, when I'm trying to set the applications to Fullscreen, the application Calendars is not activated, then I get a "System Events got an error: Can’t get window 1 of process "Calendar". Invalid index." error. This is because the Calendars window is not indexed yet, but if I delay for around 1-2 seconds after "Activate" then the script usually runs. But surely there is a way to command the script to index Calendars' windows before it tries to run the Fullscreen line? I'd like to remove the delay line of code, so that the script can run faster. Can anyone lend some ideas or solutions?
set app1 to "Maps"
set app2 to "Safari"
set app3 to "Mail"
set app4 to "Calendar"
set app5 to "Contacts"
set thelist to {app1, app2, app3, app4, app5}
repeat with i in thelist
if application i is running then
tell application i
activate
delay 0.5
end tell
tell application "System Events" to tell process i
set value of attribute "AXFullScreen" of window 1 to true
end tell
else
end if
end repeat