Run Application Minimized in Dock

Have a backup application called “backupList+” that I’m trying to automate. The script below works. app launches, backup takes place, all good. But I’d like to have this script run the app minimized in the Dock, rather than having its window fill the screen. So far I’ve been unsuccessful.

	try
		set visible of application process "backupList+" to false
	end try
	
	tell application "backupList+"
		runbackupset "Test"
	end tell
	
end tell

Getting closer, this seems to do the trick, but I’m still looking for a way to have the application (backupList+) start minimized, not be minimized.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

activate application "backupList+"

tell application "System Events" to key code 4 using {command down}

tell application "backupList+"
	runbackupset "Test"
end tell

Here’s what I ended up with:

use framework "AppKit"
use framework "Foundation"
use scripting additions

set appPath to POSIX path of "Applications" & "backupList+.app"
set workspace to current application's NSWorkspace's sharedWorkspace()
set appURL to current application's |NSURL|'s fileURLWithPath:appPath
set theConfiguration to current application's NSWorkspaceOpenConfiguration's configuration()
theConfiguration's setHides:true
workspace's openApplicationAtURL:appURL configuration:theConfiguration completionHandler:(missing value)

tell application "backupList+"
	runbackupset "Test"
end tell

It runs, does the backup, but still ends up with the application’s window on the screen.

And, it also end with this on the screen.
Screenshot

just curious… Is backupList+ one of your custom AppleScript apps? If it is, I may have a great option for you (different than my following suggestions)

Something as simple as this one line of AppleScript code may do what you’re looking for.

do shell script "open -j " & quoted form of "/Path/To/backupList+.app" -- opens the app hidden

FYI: I used the term quoted form of , just in case there are any spaces in the app’s name or its path

Because if I do something like this with the following code, I don’t see TextEdit.app or the new document created, unless I click on its icon in the dock.

do shell script "open -j " & quoted form of "/System/Applications/TextEdit.app"

repeat until application "TextEdit" is running
	delay 0.1
end repeat

tell application "TextEdit"
	make new document with properties {name:"test"}
end tell

tell application "System Events"
	set value of attribute "AXHidden" of application process "TextEdit" to true
end tell

Not one of my creations. It’s a backup application by a guy who is active on this site for quite some time (https://robdutoitsoftware.com/backuplist).

Tried this as well with the same results (minus the popup “The file can’t be found”). The application seems to defy running minimized to the Dock.

Tried this script as well. When I ran it just as it is written, Text Edit behaved just as it did for you. Sitting in the Dock waiting for input. Changed the script for backupList+ and we’re back to the app window up on the screen.

So, with a very simple script I can get backuplist+ to open, run either my local or remote backups, and then politely close. I can live with that.

Thanks for trying, on my system it also works with Apple’s Calendar, but fails with backupList+. Like I said above, I’m going to have to let this go. This best solution so far is:

tell application "backupList+"
	activate
end tell
tell application "System Events"
	try
		set visible of application process "backupList+" to false
	end try
	
	tell application "backupList+"
		runbackupset "Test"
	end tell
end tell

The app itself is on the screen for just an instant, then minimized to the Dock, it does the selected backup, and quits. Just a bit shy of what I set out to do, but not all that bad.

Nothing is going to work and I think it finally hit me as to why. When you run backupList+ the normal way, open app, select the backup and hit run, the program has an animation (totally unnecessary in my opinion) that happens the full width of the application’s window. So even if you hide the program (Command +H) it will pop right back up as soon as you trigger a backup. Thanks for your help, but I’ve given up!

This works pretty well and is probably the closest to achieving the results you were looking for.

ignoring application responses
	tell application "backupList+"
		activate
		runbackupset "Test"
	end tell
end ignoring

repeat while application "backupList+" is running
	try
		tell application "System Events"
			set value of attribute "AXHidden" of process "backupList+" to true
		end tell
	end try
end repeat

Thanks for trying, but on my 2020 M1 MacBook Pro it does nothing. The application opens (full window on screen) and just sits there. Pretty similar to my post #11, where it worked almost flawlessly on the MacBook Pro, but completely failed on my 2014 Mac mini. As I said before, thanks to everyone who tried, but I’ve moved this to the “it’s never going to work” pile.