Auto-Install Software

Give this a go, @noisneil. Long-form and arrow-headed for readability.

It seems the trick is to select the row containing the checkbox before you click the checkbox...

tell application "System Events"
	tell application process "Installer"
		tell window 1
			tell group 1
				tell splitter group 1
					tell group 1
						tell scroll area 1
							tell outline 1
								repeat with eachRow in (get every row)
									set cbName to name of checkbox 1 of eachRow
									if cbName contains "AAX" or cbName contains "VST" then
										select eachRow
										tell checkbox 1 of eachRow
											click
										end tell
									end if
								end repeat
							end tell
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

You can see the "default" install choices with (assuming the Fuse installer .pkg is on your Desktop)

installer -showChoicesXML -pkg ~/Desktop/Fuse\ Audio\ Labs\ VCL-4.pkg -target LocalSystem

You can then create a "choice changes file" -- an XML file that the installer merges with the original to create an install solution it can then run.

That's as much of the theory as I know -- and I have never done this in practice! I'll dig further if the AS above isn't working, coz it's something I should learn about anyway...

More info available via the Terminal with man installer if you're interested.

2 Likes

You've only gone and nailed it! Thankyou so much!!! The only way it could be improved is if the list of strings to check for could be set as a KM variable and then iterated in the AS.

But that's just me being greedy.

Greed is good! :wink:

Set the first action, one search term per line:

Installer Setter.kmmacros (2.6 KB)

Image

AS code, in case text wrapping hides the changes
set inst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
	set searchStrings to getvariable "Local_theSearchStrings" instance inst
end tell

tell application "System Events"
	tell application process "Installer"
		tell window 1
			--activate
			tell group 1
				tell splitter group 1
					tell group 1
						tell scroll area 1
							tell outline 1
								repeat with eachRow in (get every row)
									set cbName to name of checkbox 1 of eachRow
									repeat with eachItem in (every paragraph of searchStrings)
										if cbName contains eachItem then
											select eachRow
											tell checkbox 1 of eachRow
												click
											end tell
											exit repeat
										end if
									end repeat
								end repeat
							end tell
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell
1 Like

No.

The list of lists is the point and for demonstration.

You're code returns a list of lists – yes?

Play with the code – step through it in Script Debugger and see how it works...

1 Like

Amazing! Couldn't be happier with it and I've learned loads! Thanks everyone.

Here's the finished thing:

Auto-Install Plugins.kmmacros (60 KB)

Macro screenshot

Usage: Select one or more installers in the Finder and trigger this macro.

4 Likes

I noticed that this occasionally fails for slightly non-standard installers, where the UI element hierarchy is slightly different.

I had a think and realised that KM's Press a Button action might be a better route than AppleScript, but there's a snag.

Let's say I want to deselect Third Party Resources by clicking the relevant button:

This action will click it:

However, it seems to be clicking the button twice. Blink and you'll miss it, but it does flash briefly. Is there a way to get around this?

CleanShot 2024-12-22 at 10.21.35

What happens if you change the action to "Cancel a button named:"?

image

Nothing at all.

I have found one other thing. The Press button named action does press the button if its row is selected. I can't think of a way to make that work in the macro though.

CleanShot 2024-12-22 at 17.45.11

So the same problem as we had with the AS version?

Perhaps it's time to revisit the installer and choiceChanges method...

1 Like

It makes me a bit nervous that things would be installed without any visual feedback at all. Here's how I think it might work, but this is as yet completely untested:

Plugin Installer Script.kmmacros (23 KB)

Macro screenshot

Wow! I’ve been continuing to manually do this (creating xml files for each installer I have to automate the install for) but this method could be very promising. I’ll check it out!

Also I haven’t had any issues at all using this silent install method, I’m primarily using it to generate commands send via my company’s MDM to install packages on all of our studio computers.

1 Like

I didn't have any luck with your script, but ran with the idea and came up with a (mostly) working script with a few functional changes, which, for my cases (running a script via an MDM with secure token access as root) i'm comfortable with.

However, doing some digging it seems like you are assuming the user (you) will be modifying the sudoers file to enable passwordless sudo with the install command. Once you do that, this script should work, but I don't personally feel comfortable enabling that for a command as potentially destructive as 'installer'.

Another method could be saving each of these scripts as a script file, running it via terminal and getting the password for sudo via standard input, but

  1. I'm not sure how to then access KM Variables
  2. You'd be entering the password for every installer, defeating the purpose of this whole thing.

On second thought... probably the way around this is hard coding your desired plug-in formats in a script file, and executing the script with multiple parameters, being your selected .pkg files. So you could run the script file from KM, only get prompted once for your password via terminal and go from there.

But, here's the macro/script, which works, assuming you've allowed passwordless sudo of 'installer', but otherwise is not functional, as sudo won't take the password as standard input when run from KM as far as i can tell.

Plugin Installer Script copy.kmmacros (10.1 KB)

1 Like

Have you seen this?

Might be a good option and would also satisfy my need for some visuals.

Very cool, yeah that could definitely help passing a list of PKG files and formats to a script file, and a lot of other useful stuff where you'd want visual feedback from a script run.

Globals are easy enough. Assuming a KM variable Global_currentFrontAppName:

kmFrontAppName=$( osascript -e "tell application \"Keyboard Maestro Engine\" to return getvariable \"Global_currentFrontAppName\" " )

Instance/locals are little more difficult, but not much -- assuming you are putting text into Terminal from a macro that has access to those variables. Just set an environment variable to %ExecutingInstance% amongst the rest of the text you're inputting:

Demo:

Local in Terminal.kmmacros (3.2 KB)

Image

If you chain the installations within a single Terminal session you'll probably only have to enter your password once for sudo (unless you've changed the default duration or the installers take a very long time to run).

1 Like