This is extremely elementary for most of you in this forum, but I wanted a keyboard shortcut for Pages that would hide or show both the Toolbar and the Inspector simultaneously when invoked. My goal was to create a “Writing Focus Mode” in Pages similar to that mode in Scrivener. I “explained” to ChatGPT 4o what I wanted to do and uploaded a screenshot of my first attempt in Keyboard Maestro. ChatGPT gave me step-by-step instructions. I’m almost embarrassed to post this, knowing how elementary this is for most of you, but it was a big help and provided a way for me to learn more about creating automations.
Can you show the chatgpt transcript as well? I don’t really understand how you got from A to B.
Sure, here it is:
In Apple Pages create a keyboard shortcut to
Hide the tool bar
Hide format and format options
And another shortcut to :
Show the tool bar
Show format and format options
To create these Keyboard Maestro macros for Apple Pages, follow these steps:
Step 1: Hide the Toolbar and Format Options
-
Open Keyboard Maestro and create a new macro group for Apple Pages:
- Click on the “+” button in the lower left corner of the “All Macros” column.
- Name the new group “Apple Pages Macros”.
- Set the group to be available in “Pages”.
-
Create a new macro for hiding the toolbar and format options:
- Click on the “+” button at the bottom of the Macros column to create a new macro.
- Name the macro “Hide Toolbar and Format Options”.
-
Add actions to the macro:
- Click on “New Action”.
- Use the search bar to find the action “Select or Show a Menu Item”.
- Add two “Select or Show a Menu Item” actions to the macro.
-
Configure the actions:
- For the first action:
- Set the “Menu Title” to “View”.
- Set the “Menu Item” to “Hide Toolbar”.
- For the second action:
- Set the “Menu Title” to “View”.
- Set the “Menu Item” to “Hide Format and Format Options”.
- For the first action:
-
Assign a hotkey trigger:
- Click on “New Trigger” and choose “Hot Key Trigger”.
- Press the desired key combination, such as
⌘
+⌥
+H
.
Step 2: Show the Toolbar and Format Options
-
Create another new macro for showing the toolbar and format options:
- Click on the “+” button at the bottom of the Macros column to create a new macro.
- Name the macro “Show Toolbar and Format Options”.
-
Add actions to the macro:
- Click on “New Action”.
- Use the search bar to find the action “Select or Show a Menu Item”.
- Add two “Select or Show a Menu Item” actions to the macro.
-
Configure the actions:
- For the first action:
- Set the “Menu Title” to “View”.
- Set the “Menu Item” to “Show Toolbar”.
- For the second action:
- Set the “Menu Title” to “View”.
- Set the “Menu Item” to “Show Format and Format Options”.
- For the first action:
-
Assign a hotkey trigger:
- Click on “New Trigger” and choose “Hot Key Trigger”.
- Press the desired key combination, such as
⌘
+⌥
+S
.
Summary
You should now have two macros set up in Keyboard Maestro:
- “Hide Toolbar and Format Options” triggered by
⌘
+⌥
+H
. - “Show Toolbar and Format Options” triggered by
⌘
+⌥
+S
.
These macros will allow you to quickly hide and show the toolbar and format options in Apple Pages using your defined keyboard shortcuts.
I’m getting an error message. Can you read a screenshot to help me trouble shoot?
The error message indicates that the macro failed because it couldn’t find the target menu item “View > Hide Format and Format Options.” Here are a few steps to troubleshoot and fix this issue:
1. Verify Menu Path
Make sure the menu path in Apple Pages is correct. Open Pages and check the exact menu items under the “View” menu to ensure they are named “Hide Toolbar” and “Hide Format and Format Options.”
2. Adjust Menu Item Names
Sometimes, the menu item names might be slightly different. For example, they might be named slightly differently based on the context (e.g., if the format options are already hidden, the menu might show “Show Format and Format Options” instead).
3. Modify the Macro
If the menu items are context-dependent (changing between “Show” and “Hide”), you can create a macro that toggles the state. Here’s how to adjust the macro:
Hide Toolbar and Format Options
- Modify the Macro:
- Add a conditional action that checks if the toolbar is visible.
- If visible, it hides the toolbar and format options.
- If already hidden, it does nothing.
Show Toolbar and Format Options
- Modify the Macro:
- Add a conditional action that checks if the toolbar is hidden.
- If hidden, it shows the toolbar and format options.
- If already shown, it does nothing.
Example of Modified Macro in Keyboard Maestro
Hide Toolbar and Format Options
-
New Macro:
- Name: “Toggle Toolbar and Format Options”
- Trigger:
⌘
+⌥
+T
-
Actions:
- Add “If Then Else” action.
- Condition: If the menu item “View > Hide Toolbar” exists.
- Then: Add the actions to “Select Menu Item” for “View > Hide Toolbar” and “View > Hide Format and Format Options”.
- Else: Do nothing.
Steps to Add Actions:
-
Open Keyboard Maestro and select your macro.
-
Add “If Then Else” action:
- Click on “New Action”.
- Search for “If Then Else” and add it to your macro.
-
Set the condition:
- Condition: The menu item “View > Hide Toolbar” exists.
-
Add the “Then” actions:
-
Action: Select Menu Item
-
Menu Title: “View”
-
Menu Item: “Hide Toolbar”
-
Action: Select Menu Item
-
Menu Title: “View”
-
Menu Item: “Hide Format and Format Options”
-
-
Leave the “Else” actions empty.
Testing
Test the macro after making these adjustments to ensure it correctly hides and shows the toolbar and format options.
If you still encounter issues, please let me know the exact names and states of the menu items under the “View” menu in Apple Pages, and I’ll provide further assistance.
That is pretty cool, I would never have guessed it could do something like that for a niche app like Keyboard Maestro. I have had varying degrees of success with Excel formulas, but even when it fails, it gets me on the right track.
That is pretty cool
I think it is, too. AI has the potential to be a boon for those of us who know nothing about coding or programming but would still like to take advantage of automation. And, using AI in this fashion serves as a form of tutor, teaching one how to go about creating automations.
Have you tried it with the Shortcuts app? I always struggle getting it to do what I want, and the various guides never help much.
Not yet, but I’m sure I will at some point. And this is only going to get better and more accurate over time.
This is really cool! Thanks for sharing that! I have been wanting to automate some things with KM recently so maybe I’ll try this to figure it out.
I just realized some may want to see the result of invoking this simple KM Macro. As you can see, it is very clean for focused writing. I use keyboard shortcuts to add styles; consequently, my hands seldom leave the keyboard. This is a screenshot of a blog article I’m working on.
I think in the future, we might potentially not need automation tools since AI agents like this will perform the work for us (if integrated properly with the OS and other software). I hope we don’t reach there soonish since I love creating this automations, but I’m not very optimistic. Lol
I hope we don’t reach there soonish since I love creating these automations
I can understand that, but for the rest of us “automation Neanderthals,” we can’t wait.
(Image courtesy of AI)
Nice job! It’s all about knowing what’s possible and asking good questions.
I think that the LLM AI’s will (are) particularly helpful for the languages that are derisively called “read only.” These languages tend to be easy to follow once you have the code in front of you, but are hard to write. Apple Script is a famous member of this group. AI is very helpful in this arena.
Once the AI writes the code for you, you can follow the logic pretty easily and get inspired to make modifications and such.
This is a special payoff for products like KM that have had a community of devoted, helpful people contributing to an active forum for a long time. AI’s thus have access to a lot of sample code dealing with “problems” that people have encountered.
This is perfect fodder for an AI.
That’s a great idea! I always thought (back in the 90s) that what we needed was a Perl-to-AppleScript translator, because Perl was quick to write but impossible to read, and AppleScript was easy to read but impossible to write!
Now, we could probably do that…