How to nicely check if the app is running in full screen mode?

I have this macro that I want to use on System startup to bootstrap my applications. It looks like this:

Open all main apps on fresh restart.kmmacros (31.8 KB)

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.

Thank you for any help.

Setting some timeout between the macros worked out for me in the end. But I am open to improving and making it better if possible.

Open all main apps on fresh restart .kmmacros (36.0 KB)

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:

Activate App and Set to Fullscreen.kmactions (3.8 KB)

##Key AppleScripts

###Make Front App Fullscreen

------------------------------------------------------------
# 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!

1 Like

Thank you very much @gglick

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).

Hi again @nikivi,

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:

Activate App and set to Fullscreen.kmactions (3.2 KB)

If you're still interested in improving this macro, why not give this pure KM solution a shot and see if it works any better?