Skip to content

Commit

Permalink
updated collapse all script and added demo
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-funderburg committed Sep 8, 2020
1 parent e9c5831 commit 81a0109
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 41 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

global allActions

set allActions to {}

tell application "Keyboard Maestro"
set m to first macro whose selected is true
set acts to a reference to m's actions
my getAllActions(m's actions)
repeat with a in allActions
if a's name contains "Pause for" or ¬
a's name contains "Type the" or ¬
a's name contains "Notification" or ¬
a's name contains "Cancel" or ¬
a's name contains "Execute Macro" or ¬
a's name contains "Paste from Named" or ¬
a's name contains "Delete Past Clipboard" or ¬
a's name contains "in the Menu" or ¬
a's name contains "Set Variable" then

if disclosed of a is true then set disclosed of a to false

end if
end repeat
end tell

# recursively get every action within macro
on getAllActions(actionList)
local actionList
tell application "Keyboard Maestro"

if (class of actionList = list or ¬
class of actionList = action list) ¬
and (count of items of actionList) > 0 then

repeat with act in actionList
my getAllActions(act)
end repeat

else if class of actionList = case entry then

if (count of actionList's actions) > 0 then
my getAllActions(actionList's actions)
end if

else if class of actionList = action then

set end of allActions to actionList

-- groups
try
if (count of actionList's actions) > 0 then
my getAllActions(actionList's actions)
end if
end try
-- switch statements
try
if (count of actionList's case entries) > 0 then
my getAllActions(actionList's case entries)
end if
end try
--if then actions
try
if actionList's thenactions missing value then
my getAllActions(actionList's thenactions's actions)
end if
end try
-- if else actions
try
if actionList's elseactions missing value then
my getAllActions(actionList's elseactions's actions)
end if
end try

end if

end tell
end getAllActions

28 changes: 16 additions & 12 deletions Keyboard-Maestro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ Scripts for use while working in [Keyboard Maestro][kmapp].
![demo](../imgs/km-editscript.gif)

- [Add|Remove Status Menu Trigger][c2d0b8f9]&emsp;<kbd>⌥</kbd><kbd>S</kbd>
- Quickly add or remove a status menu trigger, best when mapped to a shortcut key.
- Quickly add or remove a status menu trigger, best when mapped to a shortcut key.

- [Collapse all Pause|Type|Execute Macro Actions][a0794034]&emsp;<kbd>⌥</kbd><kbd>⌃</kbd><kbd>[</kbd>
- I like to keep `Type Text`, `Pause for`, and `Execute Macro` actions collapsed for neatness so this is a nice script to collapse all of them in the front macro
- [Collapse All [Pause|Type|Execute|Cancel|Paste|Delete|Menu] Actions][a0794034]&emsp;<kbd>⌥</kbd><kbd>⌃</kbd><kbd>[</kbd>
- I like to keep these actions collapsed to keep my macros neat: `Type Text`, `Pause for`, `Execute Macro`, `Type the keystroke`, `Notification`, `Cancel`, `Paste from Named Clipboard`, `Delete Past Clipboard`, `Select Menu Item`, `Set Variable`
- This script makes this easy by using the script [Recursively Get Every Action][jf9jsn87] then collapsing them for me
- Demo:
![collapse](../imgs/km-collapse-actions.gif)

- [Copy Front Macros AppleScript Trigger][d4cdec98]&emsp;<kbd>⌘</kbd><kbd>⌃</kbd><kbd>C</kbd>
- Copies the AppleScript trigger for the front macro without having to show the script snippet, best when mapped to a shortcut key.
- Result looks like:
- Copies the AppleScript trigger for the front macro without having to show the script snippet, best when mapped to a shortcut key.
- Result looks like:

```AppleScript
# ignoring application responses
tell application "Keyboard Maestro Engine"
Expand All @@ -36,23 +40,23 @@ Scripts for use while working in [Keyboard Maestro][kmapp].
```
- [Edit Last Executed Macro][2f47df90]&emsp;<kbd>⌃</kbd><kbd>⇧</kbd><kbd>E</kbd>&emsp; :earth_americas:
- Global script that shows the last executed macro, great when an edit needs to be made after execution.
- Global script that shows the last executed macro, great when an edit needs to be made after execution.
- [Edit Macro Group of Front App][bca5fefd]&emsp;<kbd>⌘</kbd><kbd>⌥</kbd><kbd>K</kbd>&emsp; :earth_americas:
- Quickly jump to the macro group of the app you're currently in.
- Quickly jump to the macro group of the app you're currently in.
- [Go To Executed Macro][8f04478c]&emsp;<kbd>⌘</kbd><kbd>⌥</kbd><kbd>G</kbd>
- Jump to the macro being called within a macro by the `Execute Macro` action.
- Jump to the macro being called within a macro by the `Execute Macro` action.
- [Recursively Get Every Action][jf9jsn87]
- This is a useful subroutine to get _every_ action of the front macro, even those nested within if/else statements, switch statements, groups, etc.
- This is a useful subroutine to get _every_ action of the front macro, even those nested within if/else statements, switch statements, groups, etc.
- [Renumber Macro Number Prefix][7037aad4]&emsp;<kbd>⌘</kbd><kbd>⌃</kbd><kbd>3</kbd>
- Batch rename macros to give them ordered number prefixes, or clear the prefixes altogether.
![demo](../imgs/km-renumbermacros.gif)
![demo](../imgs/km-renumbermacros.gif)
- [Run Current Macro](./Run-Current-Macro.applescript)&emsp;<kbd>⌘</kbd><kbd>⌃</kbd><kbd>R</kbd>&emsp; :earth_americas:
- Crucial action, I use it all the time to test out the macro I'm working on but haven't set a trigger for it yet.
- Crucial action, I use it all the time to test out the macro I'm working on but haven't set a trigger for it yet.
[kmapp]: https://www.keyboardmaestro.com/
Expand All @@ -65,4 +69,4 @@ Scripts for use while working in [Keyboard Maestro][kmapp].
[8f04478c]: ./Go-To-Executed-Macro.applescript
[jf9jsn87]: ./Recursively-Get-Every-Action.applescript
[7037aad4]: ./Renumber-Macro-Prefix-Numbers.applescript
[a0794034]: ./Collapse-All-[Pause|Type|Execute-Macro]-Actions.applescript
[a0794034]: ./Collapse-All-[Pause|Type|Execute|Cancel|Paste|Delete|Menu]-Actions.applescript
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Collection of AppleScripts I've developed or acquired over the years. Some are g

> This repo is in continuous development and will be updated as scripts are developed (and as I have time).
<details>
<summary><strong>Table of Contents</strong> (click to expand)</summary>
<!--<details>
<summary><strong>Table of Contents</strong> (click to expand)</summary> -->

<!-- TOC depthFrom:2 -->

Expand All @@ -31,13 +31,14 @@ Collection of AppleScripts I've developed or acquired over the years. Some are g
- [To-Do](#to-do)

<!-- /TOC -->
</details>
<!-- </details> -->

<a id="about"></a>

## About

This repo was created for two main reasons.

1. Provide others with useful scripts for automating their workflow on macOS.
2. As a tool for AppleScript education by providing example scripts, tools, tips and AppleScript resources.

Expand Down Expand Up @@ -87,7 +88,7 @@ Application | Scripts
<i></i> | <i></i> | <i></i> | <i></i>
**[Keyboard Maestro][km]** | [Edit Linked or In-Line AppleScript][3034f6a6] | :cinema: | <kbd>⌥</kbd><kbd>⇧</kbd><kbd>E</kbd>
<i></i> | [Add\|Remove Status Menu Trigger][8111e7c4] | <i></i> | <kbd>⌥</kbd><kbd>S</kbd>
<i></i> | [Collapse all Pause/Type/Execute Macro Actions][a0794034] | <i></i> | <kbd>⌥</kbd><kbd>⌃</kbd><kbd>[</kbd> |
<i></i> | [Collapse All Pause/Type/Execute/Cancel/Paste/Delete/Menu Actions][a0794034]|:cinema:| <kbd>⌥</kbd><kbd>⌃</kbd><kbd>[</kbd> |
<i></i> | [Copy Front Macro's AppleScript Trigger][4945c497] | <i></i> | <kbd>⌘</kbd><kbd>⌃</kbd><kbd>C</kbd>
<i></i> | [Edit Last Executed Macro][8265051f] | :earth_americas: | <kbd>⌃</kbd><kbd>⇧</kbd><kbd>E</kbd>
<i></i> | [Edit Macro Group of Front App][bca5fefd] | :earth_americas: | <kbd>⌘</kbd><kbd>⌥</kbd><kbd>K</kbd>
Expand Down Expand Up @@ -141,7 +142,7 @@ Application | Scripts
[km]: ./Keyboard-Maestro
[3034f6a6]: ./Keyboard-Maestro/Edit-Linked-or-In-Line-AppleScript.applescript
[8111e7c4]: ./Keyboard-Maestro/Add|Remove-Status-Menu-Trigger.applescript
[a0794034]: ./Keyboard-Maestro/Collapse-All-[Pause|Type|Execute-Macro]-Actions.applescript
[a0794034]: ./Keyboard-Maestro/ollapse-All-[Pause|Type|Execute|Cancel|Paste|Delete|Menu]-Actions.applescript
[4945c497]: ./Keyboard-Maestro/Copy-Front-Macros-AppleScript-Trigger.applescript
[8265051f]: ./Keyboard-Maestro/Edit-Last-Executed-Macro.applescript
[bca5fefd]: ./Keyboard-Maestro/Edit-Macro-Group-of-Front-App.applescript
Expand Down
30 changes: 16 additions & 14 deletions Script-Debugger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,45 @@ Scripts and clippings for use when working in [Script Debugger](https://latenigh
## Contents

- [Duplicate Tab](./Duplicate-Tab.applescript)&emsp;<kbd>F7</kbd>
- Duplicates the front tab, useful for making edits without breaking what is already written.
- Duplicates the front tab, useful for making edits without breaking what is already written.

- [Handler Tester][9b6bdfdc]&emsp;<kbd>F6</kbd>
- This creates a second script for unit testing handlers within a script.
- Result looks something like this:
- This creates a second script for unit testing handlers within a script.
- Result looks something like this:

```AppleScript
tell application "Script Debugger"
tell document "Kevin's Library"
waitForSafariToLoad()
end tell
tell document "Kevin's Library"
waitForSafariToLoad()
end tell
end tell
```
- [Insert Dynamic Handler Description][hdnkas73]
- Insert a handler description at the beginning of the handler currently selected. The description will inserted by creating a Script Debugger clipping _dynamically_ with the handler's name and parameters.
- Check out the demo below.
- Insert a handler description at the beginning of the handler currently selected. The description will inserted by creating a Script Debugger clipping _dynamically_ with the handler's name and parameters.
- Check out the demo below.
<p><img src="../imgs/sdb-dynamicdescription.gif" width="500"</p>
- [Open Used Script Libraries][k9g57d35]&emsp;<kbd>⌃</kbd><kbd>⌥</kbd><kbd>O</kbd>
- Open the script libraries that are currently in use in the front script.
- Open the script libraries that are currently in use in the front script.
- [Run Front Script][f4s6h3f9]&emsp;<kbd>hyperkey</kbd><kbd>R</kbd>&emsp; :earth_americas:
- Execute the frontmost script globally, I use this constantly for testing scripts in other applications.
- Execute the frontmost script globally, I use this constantly for testing scripts in other applications.
- [Toggle Minimal View][e30bd9c8]&emsp;<kbd>⌘</kbd><kbd>⌥</kbd><kbd>⇧</kbd><kbd>M</kbd>
- Hides/Shows the toolbar, sidebar, and logging panel.
- Hides/Shows the toolbar, sidebar, and logging panel.
- [My Clippings](./My-Clippings)
- Custom clippings I've made over the years. To use them save the `.txt` files into `~/Library/Application Support/Script Debugger 7/Clippings`
- Custom clippings I've made over the years. To use them save the `.txt` files into `~/Library/Application Support/Script Debugger 7/Clippings`
### File saving
- [Duplicate for GitHub][8474e70d]
- This duplicates the front script in its current file location as a `.applescript` file with unix style line endings so it is readable on GitHub.
- This duplicates the front script in its current file location as a `.applescript` file with unix style line endings so it is readable on GitHub.
- [Save As Text Script][28c70107]&emsp;<kbd>⌃</kbd><kbd>S</kbd>
- Prompts for a location to save a file as a text script with unix line endings for readability on GitHub.
- Prompts for a location to save a file as a text script with unix line endings for readability on GitHub.
- [Save a Copy of Front Script as Text][5ecfae32]&emsp;<kbd>⌃</kbd><kbd>S</kbd>
- Same concept as the [Save As Text Script][28c70107] and [Duplicate for GitHub][8474e70d] but uses the command line to make sure a _copy_ of the front script is made. This is my favorite of the 3 for now because it works more consistently and makes saving `.applescript` files for these github posts way quicker
Expand Down
Binary file added imgs/km-collapse-actions.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 81a0109

Please sign in to comment.