QA Graphic
July 24, 2024

Overcoming Visual Studio Code Snippet Limitations

Keyboard Maestro is the way to go

Keyboard Maestro VSC

Visual Studio Code (VS Code) is a popular Integrated Development Environment (IDE) favored by developers for its flexibility, performance, and extensive customization options. One of the standout features of VS Code is its ability to create and use code snippets. These snippets can significantly boost productivity by allowing developers to quickly insert frequently used code templates, thereby reducing the need for repetitive typing.

However, despite the power and convenience offered by VS Code snippets, there are certain limitations that can restrict their effectiveness. This is where Keyboard Maestro, a powerful macOS automation tool, comes into play. In this blog post, we'll explore how Keyboard Maestro can be used to overcome some of these limitations, allowing you to create a more efficient and customized coding experience.

Limitations of Visual Studio Code Snippets

Before diving into the solutions, let's take a closer look at some of the key limitations of VS Code snippets:

  1. Lack of Logic Execution:
    VS Code snippets are primarily static text templates. They don't support executing logic or running scripts as part of the snippet expansion. This can be a limitation when you need to generate code dynamically based on certain conditions or calculations.

  2. Limited Trigger Options:
    Snippets in VS Code can only be triggered by typing specific prefixes, which might not be the most efficient method for all use cases. For instance, you might want to trigger a snippet based on specific UI events or keystrokes.

  3. No Interaction with Other Applications:
    VS Code snippets can't interact with other applications or system-level features. This means you're limited to the capabilities within the editor and can't leverage macOS-specific functionalities or tools.

  4. Dynamic Content Insertion:
    Snippets don't allow for dynamic content, such as inserting the current date, user input, or file names, unless manually programmed within the snippet.

  5. Complex Snippet Structure:
    Complex snippet structures, like multi-line or nested code blocks with various levels of indentation, can be cumbersome to create and manage.

Why Use Keyboard Maestro?

Keyboard Maestro is a robust automation tool for macOS that allows you to create macros to automate tasks across various applications. It excels in situations where traditional shortcuts and snippets fall short. Here are some reasons why Keyboard Maestro can be an excellent complement to VS Code snippets:

  • Conditional Logic:
    Keyboard Maestro can execute complex scripts and logical operations, allowing for dynamic code generation based on conditions or user input.

  • Custom Triggers:
    You can trigger macros using a wide range of inputs, including specific keystrokes, mouse clicks, or even system events, providing more flexibility than VS Code's snippet triggers.

  • Inter-application Automation:
    Keyboard Maestro can interact with other applications and system features, enabling cross-application workflows that aren't possible with VS Code snippets alone.

  • Dynamic Content and Variables:
    Easily insert dynamic content like dates, file names, or clipboard contents into your code with the help of variables and conditions.

  • Complex Code Structures:
    Automate the insertion of complex, multi-line code structures without worrying about formatting issues.

Setting Up Keyboard Maestro with Visual Studio Code

Now that we've covered why Keyboard Maestro is beneficial, let's explore how you can set it up to enhance your VS Code experience. Here's a step-by-step guide:

Step 1: Install Keyboard Maestro

If you haven't already, download and install Keyboard Maestro from the official website. Once installed, open the application to start creating your macros.

Step 2: Create a New Macro

  1. Open Keyboard Maestro and click on the + button at the bottom-left corner to create a new macro.
  2. Give your macro a descriptive name, such as "Insert Timestamp in VS Code."

Step 3: Set a Trigger

  1. Click on the "New Trigger" dropdown.
  2. Choose the desired trigger type. For instance, you might select "Hot Key Trigger" to assign a specific key combination.

Step 4: Add Actions

This is where the magic happens. You can add multiple actions to create complex workflows.

Permalink
July 17, 2024

Unleash the Power of Your Clipboard with Keyboard Maestro's Clipboard History Switcher

Powerful Tools

Ever copied something and wished you could analyze it before pasting? Struggling to remember that specific piece of text you copied a while back? Keyboard Maestro's Clipboard History Switcher comes to the rescue, offering a treasure trove of information about your clipboard contents.

More Than Just Pasting: A Peek into Your Clipboard

Sure, the Clipboard History Switcher lets you select and paste previous clipboard items, but that's just the tip of the iceberg. When you activate the switcher (by default, with the Command-Control-Shift-V shortcut), you're presented with a window displaying your clipboard history. But here's the real kicker: for each text snippet, the Clipboard History Switcher provides a wealth of metadata:

  • Character Count: Instantly see the exact number of characters in your copied text. This is perfect for adhering to character limits in forms, social media posts, or code snippets.
  • Word Count: Need a quick word count? No problem! The switcher displays the number of words, giving you a sense of the text's length.
  • Line Count: Working with text that spans multiple lines? The switcher shows the line count, helping you visualize the structure of your copied content.
  • Clipboard Size: Ever wondered how much space that copied image or text is taking up? The switcher displays the clipboard size, giving you a heads-up on potential memory usage.

Clipboard History Info

Making Informed Pasting Decisions

This information empowers you to make informed decisions about what to paste. Imagine copying a lengthy passage and needing just a specific excerpt. With the character and word count displayed, you can quickly identify the relevant section without manually counting.

Similarly, the line count helps you understand the structure of copied code or formatted text, allowing you to paste it seamlessly into your target destination.

Keyboard Maestro: Your Clipboard Management Powerhouse

The Clipboard History Switcher is just one aspect of Keyboard Maestro's robust clipboard management features. This automation powerhouse lets you not only manage your clipboard history but also manipulate clipboard content in various ways.

So next time you copy something, don't just paste blindly. Use Keyboard Maestro's Clipboard History Switcher to gain valuable insights into your clipboard contents and make informed pasting decisions. It's a simple yet powerful tool that can streamline your workflow and boost your productivity.

Permalink
June 5, 2024

Display Month Name

Quickly type out any month name

Boost your typing efficiency with Keyboard Maestro! No more wasting time spelling out month names. This handy macro automatically inserts the current month's full name whenever you activate it.

Here's my Display Month Name Macro:

K M Display Month

Four Things To Note:

In this Macro, I use multiple shortcuts to execute the same Macro. 1 through 12 -> I type in the m. and then the month that I want to display and then a space.

The Macro set the Trigger value (m.6) to a variable, then GREP the Trigger name for the month. So I just get the number.

Then I use UNIX date/time command to get the full month name. (You may notice that 2017 in the year, that doesn't matter.)

The resulting text is typed out.

Display Month Detail

In Summary

I can easily change the month name format by changing the last command and it will impact all the macro shortcuts - no need to repeat the tast multiple time.

Keyboard Maestro offers a wide range of automation tools to streamline your workflow. This is just a small example of its capabilities. Explore Keyboard Maestro to discover how it can save you time and effort on repetitive tasks.

Permalink
May 29, 2024

Multiple Words List (Python)

Sample Shell Script in Keyboard Maestro

As part of my testing process, I occasionally require a list of words. To facilitate this, I developed a Keyboard Maestro macro that generates a list of 10 random words. Previously, I had crafted a similar script in PHP, but I've recently updated it to Python 3.

While I didn't observe any performance enhancements between the PHP and Python shell scripts, I did notice a quicker display of results when utilizing the 'Paste Results' feature.

KM Multiple Words 2023
Sample Macro

Python Code


#!/usr/bin/python3
import random
# Open the file with read permission
with open("/usr/share/dict/words", "r") as file:
    words = file.readlines()
    words_length = len(words)
def random_word():
    # Choose a random word from the list
    rand_word = random.choice(words).strip()
    # Remove possessive case and capitalize the word
    description = rand_word.replace("'s", "")
    return description.capitalize()
# Generate and print 10 pairs of random words
for _ in range(11):
    print(random_word(), random_word())

One More Thing

You'll notice that I have two different shortcuts assigned to this macro. This is a neat feature of Keyboard Maestro. You can assign multiple shortcuts to perform the same action. Useful when you may know the shortcut as different things in different projects.

Next week, I'll show you a cool way to take advantage of using multiple shortcuts for the same macro.

Permalink
May 22, 2024

Parse Domain in URL

Sample Parse Functionality in Keyboard Maestro

This is a "basic" macro in Keyboard Maestro to split the URL of a new copy text in the Clipboard. This piece of code demonstrates that you don't have to trigger an action in Keyboard Maestro.

In this example the macro is triggered when a URL is pasted in the clipboard. Keyboard Maestro automatically parses the Domain name in the background.

Parse Domain URL

You can change this up to create a hyperlink to this URL or strip everything to the right of the domain name and creates a new entry on the clipboard.

Permalink
May 15, 2024

Atlassian Comment Field

Quickly add an Emoji to your Comments

In 2019, Jira switched from MediaWiki to Markdown, removing shortcuts for the green checkmark and red X emojis. (See my old Jira new Comment Field) for details - Created March 18, 2019. )

Recently, Atlassian added an emoji picker shortcut. Type ":" and scroll down to choose the emoji. Frequently used emojis appear at the top for easy access.

I created a simple Keyboard Maestro macro to insert the checkmark emoji and add text to Jira comments, making it easy to indicate feature validation.

Example in Action:

Keyboard Maestro- Jira 2024

Keyboard Maestro Macro

This is a screen shot of the Macro:

Jira Testing 2024

The pause for 1 second is needed because the macro runs much quicker than Jira's response.

Permalink
May 8, 2024

Macro Wizard

Quickly Create Macros that You Need

Keyboard Maestro now offers a streamlined tool for creating macros, making it easier for users to automate tasks quickly. This intuitive interface simplifies the process without sacrificing the power Keyboard Maestro is known for.

Macro Wizard in Keyboard Maestro

Five Things I Learned

Macro Wizard was introduced in version 11.

To activate the Wizard select the File menu and then "New Macro Wizard." You can also use the keyboard command: Option Shift Command N

Macro Wizard Cheat Sheet
Guide to show you the Keyboard Shortcut needed to trigger the new Wizard.

The Macro Wizard is a quick way to jump start a new macro, especially if you just want to add a basic shortcut. It really helps reduce the number of steps. For example, if you wanted to add a shortcut #Miss for Mississippi, using the Wizard makes this easy to add.

The seven action items are: Activate an application, Open a file, Manipulate a window, Paste some text, Type some text, Select a Menu, and Add Later. These were likely selected as the most common action items people use. Once the wizard closes you still have access to the 100s more in the Actions selector.

After you click on the "Create" button. You are presented with the regular Macro section ready for all your creativity - or to paste in the text you wish.

Try it out!

Keyboard Maestro veterans will definitely appreciate the new macro creation tool. It streamlines a process they're already familiar with, boosting their efficiency. But that doesn't mean it's exclusive to them. Even for those who are absolute masters at crafting macros, this new interface can provide a welcome alternative approach, potentially even sparking new ideas for automation workflows.

Permalink
May 1, 2024

Prompt For Snippet

Keyboard Maestro 11 elevates automation to a new level with its ability to prompt users for specific actions. This proves particularly valuable for streamlining repetitive tasks. Take my website screenshot macros, for example. Previously, I needed separate status menu items for each macro. Now, Keyboard Maestro 11 allows me to consolidate them into a single, user-friendly menu item. The user is then prompted to choose the specific website screenshot they require, eliminating menu clutter and enhancing efficiency.

Here's an example of the prompt:

Keyboard Maestro Prompt2

This is what some of the macro looks like:

Production Screenshot

Three Key things to Remember

The variable %PromptButton% has the value of what button was selected.

Keep the information and options short, don't overload the prompt with a lot of buttons and text fields. You may find that there are better options to do what your trying to do.

I find using the prompt option on macros that are triggered by the status menu.

One More Thing

Keyboard Maestro's "Prompt for Snippet" feature was a game-changer for me, justifying the upgrade to the latest version. It streamlines my workflow by allowing me to create custom text snippets on the fly. Imagine having dynamic keyboard shortcuts that prompt you for specific details before inserting the final text. This eliminates repetitive typing and lets you focus on what matters - getting things done!

Permalink
December 22, 2021

Shuffle Filter System Clipboard

Add Shuffle to your Clipboard Content

One of the neat things about Keyboard Maestro is the Clipboard History. You can easily activate the Clipboard History Switcher and get back any content that was put in the clipboard. By default Keyboard Maestro will hold the last 200 items in the Clipboard History.

Additional Filters

Along with copy/pasting previous items, you can apply some filters to the text in the clipboard history. There are 21 filters included with every Keyboard Maestro installation:

  • Capitalize
  • Display as Text
  • Flip Horizontal
  • Flip Vertical
  • Font Awesome
  • Half Size Image
  • Lowercase
  • Lowercase First
  • Lowercase then Capitalize
  • Lowercase then Title Case
  • Move to Extra Clipboard
  • OCR Image
  • Remove Styles
  • Rotate 180??
  • Rotate Clockwise
  • Rotate Counter-clockwise
  • Set DPI to Nominal
  • Title Case
  • Translate
  • Uppercase
  • Uppercase First

When you apply a filter they don't happen immediately. A new clipboard entry is created and you can paste the content in. This way you can still get the previous clipboard item for future action.

Shuffle Time

New in version 10 is the Shuffle filter. Now you can easily shuffle the contents of the clipboard. This is useful when you have a list of names that you want to shuffle.

You can find all the details on how to add a new Clipboard Filter Trigger on the Keyboard Maestro Wiki.

Example Macro

Shuffle Filter

Permalink
December 15, 2021

Backup USB items

Use Keyboard Maestro to auto backup USB drive

This week's is a followup to the "Keyboard Maestro Copy File" blog post. In this week's post, I'll show you how to use Keyboard Maestro's actions to perform the same BASH function.

This is a great example of understanding the power that Keyboard Maestro has. While the BASH code is shorter in code, I feel the Keyboard Maestro version is more flexible in doing other actions.

Simple Task

Create a Macro that will copy all the documents in a particular folder and place a copy of them in a new location based on their created date.

Actions used

  • Get File Name to Variable
  • Get File Type to Variable
  • If All Conditions Met Execute Actions
  • Get Date Created to Variable
  • Set Variable to Text
  • Create New Folder
  • Copy File

Keyboard Maestro Macro

Sony Action Steps

These are the steps in the screenshot:

  • Pause for 1.5 Seconds - Wait for the USB drive to fully mount.
  • For Each Item in a Collection - For all the files in a particular directory on the Sony Recorder execute the following actions.
  • Get File Name to Variable - Save the file name to a variable to be used later.
  • Get File Type to Variable = Identify the type of file in this loop cycle.
  • If All Conditions Met Execute Actions - Now lets take actions only on files and not folders
  • Get Date Created to Variable - Get the file created date and assign it to a variable
  • Set variable to Text - Assign the date format to a human readable format. (Example YYYY-MM-dd)
  • If All Conditions Meet Actions - Check to see if the directory exists.
  • Create New Folder - Create a new folder if it doesn't exists.
  • If All Conditions Meet Actions - Check to see if the file already got moved over.
  • Copy File = Move the selected file to the directory

Permalink

About

These posts highlights some cool examples of why Keyboard Maestro should be part of every Mac OS user's computer. Keyboard Maestro is a powerful automation tool that can help improve productivity, save time, and streamline tedious tasks. It has a wide range of features and functions that can be customized to suit any user's needs, making it an ideal choice for Mac OS users.

Check out all the blog posts.

Schedule

FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
MondayMedia Monday
TuesdayQA
WednesdayNew England
ThursdayGluten Free