I have one macro to toggle wifi on/off and another for BT. I'd like to combine them with one macro to trigger both together. (unless there's a simpler way to accomplish this). Both run simple shell scripts; both work alone.
Did you know that at the top of your macro you can have two (or more) triggers for hot keys? Can't you just add two triggers for each of your two macros which work separately? Is this clear or do you need screenshots of what I'm saying?
Yes each macro controls one function. But you can have a single keypress trigger two macros at the same time by adding extra triggers at the top of the macro. Or, at least that's how I think it should work. I've never tested that. It will look like this:
Ok try it this way. I'm sorry for being dumb today.
This new solution will call both macros, sequentially. This is more appropriate than generating keystrokes. Does this help you out? (Use Ctrl-W or whatever you want instead of the F5 key that I used.)
THanks! Sounds good. But I tried the solution of "do script [MACRO NAME]" x2, one for each of the two macrosâa solution you suggested, I saw, from the WIKI. And that does the trick. Perhaps not entirely economical, but works,
Execute AppleScript
set status to do shell script "networksetup -getairportpower en0"
if status ends with "On" then
do shell script "networksetup -setairportpower en0 off"
else
do shell script "networksetup -setairportpower en0 on"
end if
Execute AppleScript
tell application "System Preferences"
reveal pane id "com.apple.preferences.Bluetooth"
-- activate
set the current pane to pane id "com.apple.preferences.Bluetooth"
try
tell application "System Events" to tell process "System Preferences"
click button "Turn Bluetooth Off" of window "Bluetooth"
click button "Turn Bluetooth Off" of sheet 1 of window "Bluetooth" of application process "System Preferences" of application "System Events"
end tell
delay 1
on error
tell application "System Events" to tell process "System Preferences"
click button "Turn Bluetooth On" of window "Bluetooth"
quit
end tell
end try
end tell
ToggleInternet (commands both synchronously; NB: both BT and WiFi must be on or off for this command to turn off or on both)
To add this as a Better Touch Tool button on the Touch Bar (allows you to tap it to trigger the Super-Macro that triggers the two sub-macros), you simply configure a button like this (or as you wish):
If you @jipnet want to save the shortcut for your macro and want to trigger the macro via the Touch Bar with BetterTouchTool, then use the KM Macro AppleScript .
Could even reduce my shortcuts in KM by 90 percent.
appears as a red button on the Touch Bar, acts as a toggle.
Not sure what "the KM Macro AppleScript" refers to, and not sure how that could reduce KM shortcuts by 90% (the space on the Touch Bar is quite limited).
I shouldn't try speak for another person (that won't stop me from trying) but I think when he said "KM Macro AppleScript" he probably meant "the KM action Execute AppleScript", ie,
I'm not sure how he concludes that we can reduce shortcuts by 90%. Perhaps he meant if we code things in Applescirpt we can reduce our code in KM proportionately. Sure. If you eat more Apples (AppleScript) you can eat fewer Kiwis (Keyboard Maestro). But you still need to eat the same amount of fruit.
Hi @jipnet and @Sleepy, at the beginning I also assigned shortcuts in KM and then used them in BTT to set up a touch gesture.
Since this has led to overlaps with the shortcuts over time, I also changed the use of the AppleScripts included in the macros. I now use it in BTT and save myself the trouble of working with random shortcuts
I had a post here once about it:
In my post I explain how to create BTT gestures with the mouse or trackpad. You @jipnet must select then in the BTT menu only the carrier for the Touch bar.
If you want to launch the master macro (Toggle Internet) from BTT, then just use the same method you are already using for launching the two sub macros from the master macro: via AppleScript.
You find the the premade AppleScript to launch your master macro in the âOr by AppleScriptâ popup:
Then you paste that script to BTT here:
âŚand set the BTT trigger you want.
BTW, to launch the sub macros from your master macro, you can also make use of the Execute Macro action:
It is made for such cases, so no need to use an AppleScript action here.
Hello @Tom, if you are interested, I have a macro with which you can save yourself the manual copy & paste of the AppleScript between KM and BTT.
In KM your macro manners (blue) and trigger the macro. If you have selected the AppleScript action in BTT, simply press the Space key and the AppleScript will be inserted.