Where cmd + F4 is making the app go full screen. This script fails though because I want to wait until the app is full screen and then open other apps. I can work around it by setting a delay in between but perhaps there is a better solution than this.
Thanks yet again to one of @ccstone's previously shared scripts, I think I was able to figure something out. I can't set this up for every app in your macro because I don't have all of them on my system, but you should be able to repeat these actions without further modification for each app:
------------------------------------------------------------
# Auth: Christopher Stone
# Mod: Gabe Glick
# dCre: 2016/04/10 02:43
# dMod: 2017/12/22 08:30
# Appl: System Events
# Task: Set front window of front app to fullscreen.
# Tags: @Applescript, @Script, @System_Events, @Toggle, @Full, @Screen
------------------------------------------------------------
try
tell application "System Events"
tell (first application process whose frontmost is true)
tell (first window whose subrole is "AXStandardWindow")
set fullScreen to value of attribute "AXFullScreen"
if fullScreen = false then
set value of attribute "AXFullScreen" to true
end if
end tell
end tell
end tell
on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell application (path to frontmost application as text) to set ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try
------------------------------------------------------------
###Verify that Front App is Full-Screen (pauses macro until script returns "true")
tell application "System Events"
tell (first application process whose frontmost is true)
tell (first window whose subrole is "AXStandardWindow")
value of attribute "AXFullScreen"
end tell
end tell
end tell
You may be able to make do with just adding the "pause until" actions to your existing macro and keeping the ⌘F4 keystroke to activate fullscreen, but I'm including the AppleScript way here in the hope that it will prove more robust. Give this a try and let me know how it works!
This script is indeed much better. It only fails on Trello, Spotify which is due to them being Electron apps. But also surprisingly it fails on Textual IRC app too which is not on Electron. Would be nice to have a robust solution for those cases too but until then I will manually enter full screen and set timeout for those cases.
You’re welcome, @nikivi! Glad it’s proving useful. I don’t know anything about Electron, and don’t have Spotify or Textual IRC installed, but I do sometimes use Trello, and that seems to work fine with both scripts, at least on my system (10.13.2).
I feel very silly right now; I happened to stumble across native KM actions and conditions related to fullscreen stuff that I completely forgot existed, and confirmed that they work with Trello: