Applescript to automatically fullscreen Madmapper for installations

19 Sep Applescript to automatically fullscreen Madmapper for installations

This is a simple Applescript that I used with a long running installation that required Madmapper for doing some precise mapping. More info on keeping long running installations going is here: http://blairneal.com/blog/installation-up-4evr/

This script would be used on reboot to both open your Syphon enabled app and to open your madmapper file, open it, select fullscreen, and then hit OK on the dialog box.

It requires you to set your own file path in the script for your madmapper file and application file.

To use the code below:

1. Open Applescript and paste it into a new file

2. Change the filepaths and resolution so they match how it appears in your setup (ie resolution may be 3840×720 instead)

2. Go to “File -> Export” and select “Application” as your file format

3. In System Preferences -> Users & Groups -> Login items drop your applescript application in there to automatically launch on boot

 

You can also add in pauses (for things to load) and other checks with applescript if necessary.

This script will fail if for some reason the resolution has changed on boot or something – if the text doesn’t match exactly how it is in the Output menu of madmapper, it won’t work.

NOTE: I personally do not recommend using Madmapper for long running installations – there are occasional issues with it losing keyboard focus and it can appear as if your machine has locked you out if accessing it remotely. It’s also typically best practice to try and keep everything simplified into one application so you can minimize weird occurrences. In the case that we had to use this, there was not enough development time to add in the mapping code that was necessary.

 

 

tell application "Finder" to open POSIX file "YourInstallationApp.app" --add your absolute file path to your application

delay 10 --wait 5 seconds while your app loads up

tell application "Finder" to open POSIX file "/Users/you/yourmadmapperfile.map" --absolute filepath to your madmapper file

do_menu("MadMapper", "Output", "Fullscreen On Mainscreen: 1920x1200") --change this line to your determined resolution

on do_menu(app_name, menu_name, menu_item)
	try
		-- bring the target application to the front
		tell application app_name
			activate
		end tell
		delay 3 --wait for it to open
		tell application "System Events"
			tell process app_name
				tell menu bar 1
					tell menu bar item menu_name
						tell menu menu_name
							click menu item menu_item
							delay 3 --wait for Is fullscreen OK? box to appear
							tell application "System Events" to keystroke return
						end tell
					end tell
				end tell
			end tell
		end tell

		return true
	on error error_message
		return false
	end try
end do_menu