Macro to Toggle Bluetooth and Wireless?

As always many thanks for your tip @Tom :+1:
I've put this in my macro.

I know @Tom that you also use Launchbar to trigger KM macros. Can I improve my macro? Does using the KM URL or the KM AppleScript make a difference?

2019_07_13_Support_1

Actions.kmmacros (51,9 KB)

Thanks Tom. There are obviously many ways to achieve the same goal.

I just noticed that the flaw with this method (and any proposed so far) is that to toggle both on or off, both must be in the same initial state (either on or off). Otherwise, one will go on and the other off. In other words, the solution is really "analogue" and not fully "digital." (no doubt due to the scripts that do the toggling, which I found on the web ready made)

THanks. I will explore these tips in due time. Right now I have a fat red button on my control strip that performs the combined action as scripted in KM, making it a snap to turn on or off the WiFi and BT. (I read that thieves can "sniff" BT and WiFi signals in a laptop in a car, so I want to deprive them of this opportunity in as mindless a way as I can remember.)

I haven't played with BTT folders, but I imagine you can drill down several levels without leaving the keyboard. But at some point, a floating palette might be simpler (alas, not so useful in a laptop format where screen real estate is limited—though your disappearing palette may take care of that too)

1 Like

Indeed, I thought the same. Especially your “Toggle BT” macro is rather fragile, due to its heavy reliance on UI AppleScripting.

Once one macro off means you are out of sync. So maybe better to create macros to enable and disable the stuff. Not toggling.

Well, good catch, but that can be fixed by an IF statement, such as "If Wireless Network BELL101 is connected then DISABLE both networks else ENABLE both networks." That's probably an improvement. But some people might prefer toggling both, which can be done with two IF statements.

I know, you are a big fan of chained GUI actions (clicking buttons, selecting menu items, …). Me not so much :sweat:

What about this:

Not completely “automized”, but dead simple.

If you really want to create dedicated LB actions to launch KM macros, then I would simply duplicate an existing one (in Action Editor, right-click on an action), adapt the name and paste the UUID into the script.
Once again, not automized. But not much gain by “automizing” it. Especially not when automizing it with a fragile GUI macro. (I know, Action Editor is not scriptable, but there isn’t much reason to make it scriptable.)

1 Like

Hi @jipnet, thanks for posting these. When you have a moment, would you mind editing your post to include screenshots of the macros? I’m asking for me, but it’s also a good rule of thumb to do this whenever posting a macro: it’s really helpful for others to be able preview what they’ll be downloading, or even save them the effort if they can see from a visual that it’s not what they were looking for.

[ If you want to be super duper, then you can also copy any scripting code used in any macros you upload, and include them as formatted code blocks under the screenshots, but this is less important. It can, however, benefit you should someone skim a post and notice something that wouldn’t have been caught otherwise. ]

Of course. So glad to provide, finally, something in return to this incredibly helpful forum.

I'll see if I can't edit the previous post.

Done. But I don't know how to make formatted code blocks unless it's by using three ``` before and after as above (after searching for this formatting command)

1 Like

Thanks a lot. That's awesome.

There are three options of which I'm aware:

  1. Indenting a line with 4 (or more) spaces will turn that line into a code snippet that spans the width of the post. Subsequent lines that are either blank or indented 4 (or more) spaces will be added and merged to form a code block. The block ends with the last, non-blank, indented line.

  2. When typing a post, the editing area has a toolbar:


    If you select a block of text first, then click the button shown, it indents every line by 4 spaces, thus creating a code block.

  3. The simplest way, I find, is, as you found, by opening and terminating a block of text using three backticks, ```. The opening set can, optionally, specify the language that is used to help highlight its syntax appropriately, e.g.:

    ```javascript
    factorial = (x) => {
        return (x==0) ? 1 : x * factorial(x-1);
    }
    ```
    

    will be formatted and highlighted as:

    factorial = (x) => {
        return (x==0) ? 1 : x * factorial(x-1);
    }
    

    The language identifier is often not needed as it's typically detected automatically. But common identifiers include: applescript, javascript, html, shell. Your code blocks suffered the annoying consequence of having the browser attempt to paste the code with the formatting style information that was copied along with the text itself. I forget how to avoid this from happening.

1 Like

Found it: you copy the code in KBM not by command-C but by the "copy" command in the gear that controls the code entry in the macro. And the ``` before and after. tx

Some laptops come with “Wi-Fi” function keys or switches that can quickly enable or disable your Wi-Fi. If your PC doesn’t have one of these, though, you can make one with the tools built into Windows.

You’ll need to start by creating a desktop or start menu shortcut. Once you’ve done that, you can invoke it with a keyboard shortcut, if you like. shareit apk

Thanks. I use Macs.