Hold down Ctrl and open the application?

I'd like to automate the process of opening apps from unidentified developers, which requires holding down the Ctrl key, right-clicking the app's icon, choosing "Open" from the context menu, and then pressing it. Is there a reasonably simple way to do this? I've tried, but unfortunately, I can't seem to get it to work.

How about trying this?

Download Macro(s): Test Open Developer App.kmmacros (3.0 KB)

Macro-Image

Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 10.15.7
  • Keyboard Maestro v10.2

Make sure to position your mouse pointer over the app's entry in Finder before triggering the macro.

The macro right-clicks on the app to open the contextual menu and then types "Open" followed by the return key.

I thank you for your help but it is a bit annoying because, by automating other previous actions, the list of applications is not always fully visible in the window, and it risks that the command will fail.

Personally, I favour bypassing the restriction and enabling apps from anywhere in security prefs.

sudo spctl --master-disable

1 Like

Well it would seem you’re not telling us about what else you’re doing at the same time so that the problem you asked for help about is only a part of what you are trying to do. If you tell us the whole story perhaps someone might be able to help.

On the other hand, maybe @noisneil’s suggestion will get you there…

Of course. The goal is to automate the installation of updates for the LibreWolf browser, which by design doesn't offer automatic updates (meaning it has to be installed manually each time) and lacks a valid signature (hence the need for a "ctrl+open" action). This last step is the hardest to get around. I can automate everything up to that point: 1) open the dmg from the downloads folder, 2) copy the .app from the installation volume to the applications folder, 3) eject the volume and close the windows.

@noisneil 's solution, which I appreciate for its suggestion (I was wondering if it was possible to initiate the "ctrl+open" process from the shell), is undoubtedly the most straightforward approach. However, I'm still looking for other solutions to avoid potentially compromising the security of my operating system.

Disabling Gatekeeper with sudo spctl --master-disable doesn't immediately put your system at risk, but it does remove a layer of security that helps protect against inadvertently installing malicious software. Even with Gatekeeper disabled, you typically need to explicitly execute or install software to expose yourself to potential risks.

I'm with you on that :slightly_smiling_face:

OK - this macro first reveals the target app in Finder and then initiates the contextual menu; after that it types "Open" and the return key. You don't need to position the mouse first.

You can incorporate the 5 actions in your own macro but it's important that you put the full path to the target app into the action coloured red.

Download Macro(s): Test Open Dev App.kmmacros (4.8 KB)

Macro-Image

Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 10.15.7
  • Keyboard Maestro v10.2
1 Like

Hmm.. doesn't work for me:

CleanShot 2023-10-13 at 11.50.09

I'm not surprised. Try upgrading (!) to Catalina first :rofl:

I'm on Ventura. Might explain it.

Ok, this opens the contextual menu successfully on my system:

tell application "System Events"
	set frontApp to name of first process whose frontmost is true
	tell application process frontApp
		try
			set theSelection to value of attribute "AXFocusedUIElement"
			tell theSelection
				set defaultAction to perform action "AXShowMenu"
				if defaultAction is missing value then
					tell (first group whose selected is true) to perform action "AXShowMenu"
				end if
			end tell
		on error errMsg number errNum
			display alert errMsg & return & return & errNum
		end try
	end tell
end tell

Here it is in your macro:

Test Open Dev App.kmmacros (22 KB)

Macro screenshot

1 Like

I love it @noisneil - one date I'll be able to test it :man_shrugging:

Off topic: why do you guys like '70s - sorry - Dark Mode so much? Red on Black really doesn't work for me!!

2 Likes

Hey @noisneil - your version works for me :smiley: so I'll be adding a note to the thread where I nicked it from originally to point to your version. Nice!!

EDIT: so now I'm going to nick your version - thanks!

1 Like

I find light mode tiring on the eyes. It also drains device batteries quicker.

What's red on black?

It worked! :grimacing:

1 Like