Deactivate group with applescript?

In which case the KM Editor is open and you don't mind that -- that saves a lot of work!

It's in (under?) the words "this thread". Or, explicitly: https://forum.keyboardmaestro.com/t/difference-between-group-enable-disable-vs-activate-deactivate/

Note that you need to get the UUIDs of the Groups to deactivate, not the names. Something like this should do it:

Deactivate "•" Groups Programmatically.kmmacros (2.5 KB)

Image

The AppleScript:

tell application "Keyboard Maestro"
	set groupList to (get id of every macro group whose name starts with "•")
end tell

tell application "Keyboard Maestro Engine"
	repeat with UUID in groupList
		do script "<dict>
		<key>DisplayToggle</key>
		<true/>
		<key>MacroActionType</key>
		<string>MacroGroupToggle</string>
		<key>MacroGroupUID</key>
		<string>" & UUID & "</string>
		<key>ToggleMode</key>
		<string>Deactivate</string>
	</dict>"
	end repeat
end tell

I've left DisplayToggle on <true/> so you get an indicator -- change to <false/> if that annoys. If you want to use the same macro to toggle the Groups between "activated" and "deactivated", change ToggleMode to Toggle.

1 Like