Skip to content

Commit

Permalink
updated my clippings, fixed gif
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-funderburg committed Dec 13, 2019
1 parent 84b685f commit 0d32487
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Keyboard-Maestro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Scripts for use while working in [Keyboard Maestro][kmapp].
- [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/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.
Expand Down
80 changes: 47 additions & 33 deletions Keyboard-Maestro/Renumber-Macro-Prefix-Numbers.applescript
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "System Events"
display dialog "Enter the starting number or click clear to remove number prefix." default answer 0 with title "Renumber Macro Prefix Numbers" buttons {"Cancel", "Clear", "OK"} default button "OK"
end tell
tell result
set buttonReturned to button returned
set strt to text returned as number
end tell


tell application "Keyboard Maestro"
set sel to selection
if class of item 1 of sel macro then error "Invalid selection, please select macro(s)"
set n to strt
repeat with m in sel
set nm to m's name
try
tell application "Keyboard Maestro"

if buttonReturned = "Clear" then
set newname to characters 4 thru -1 of nm as text
tell m
set name to newname
end tell
else
if n < 10 then set n to "0" & n
tell m
if character 3 of nm is ")" then
set newname to n & (characters 3 thru -1 of nm) as text
else
set newname to (n & ")" & nm) as text
set dialogResult to display dialog ¬
"Enter the starting number or click clear to remove number prefix." default answer 0 ¬
with title "Renumber Macro Prefix Numbers" buttons {"Cancel", "Clear", "OK"} ¬
default button "OK" with icon ¬
POSIX file "/System/Volumes/Data/Applications/Keyboard Maestro.app/Contents/Resources/kmicon.icns"
set startNum to dialogResult's text returned as number

set sel to selection
if class of item 1 of sel macro then error "Invalid selection, please select macro(s)"
set n to startNum
repeat with m in sel
set oldname to m's name

if dialogResult's button returned = "Clear" then

if character 3 of oldname = ")" then -- 2 digit number prefix
set newname to characters 4 thru -1 of oldname as text
else if character 2 of oldname = ")" then -- 1 digit number prefix
set newname to characters 3 thru -1 of oldname as text
else -- doesn't have a number prefix
set newname to oldname
end if

else
if n < 10 then set n to "0" & n

if character 3 of oldname is ")" then
set newname to n & (characters 3 thru -1 of oldname) as text
else if character 2 of oldname is ")" then -- 1 digit number prefix
set newname to n & (characters 2 thru -1 of oldname) as text
else -- doesn't have a number prefix
set newname to (n & ")" & oldname) as text
end if
set name to newname
end tell
set n to n + 1
end if
end repeat
end tell
set n to n + 1

end if
set m's name to newname
end repeat
end tell

on error errMsg number errNum
if errNum -128 then
display dialog errMsg & return & return & errNum buttons {"Cancel", "OK"} ¬
default button "OK" with icon caution
end if
end try

Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
-- @description
-- [[template:description]]
--
-- @param $[[template:param1]] - [[template:param1description]]
-- @param $[[template:param2]] - [[template:param2description]]
--
-- @description-- [[template:description]]---- @param $uid - [[template:description]]--
Expand Down
1 change: 1 addition & 0 deletions Script-Debugger/My-Clippings/Script Libraries/Alfred.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[*library:al::Alfred Library]]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[*library:acl::AppleCare Library]]
1 change: 1 addition & 0 deletions Script-Debugger/My-Clippings/Script Libraries/BTT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[*library:bl::BetterTouchTool Library]]
1 change: 1 addition & 0 deletions Script-Debugger/My-Clippings/Script Libraries/Kevin's.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[*library:kl::Kevin's Library]]
1 change: 1 addition & 0 deletions Script-Debugger/My-Clippings/Script Libraries/coreGUI.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[*library:cl::coreGUIelements]]
1 change: 1 addition & 0 deletions Script-Debugger/My-Clippings/application hfs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[template:applicationhfs]]
1 change: 1 addition & 0 deletions Script-Debugger/My-Clippings/application posix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[template:applicationposix]]
5 changes: 4 additions & 1 deletion Script-Debugger/My-Clippings/display dialog.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
display dialog "[[template:message]]" buttons {[[template:"Cancel", "OK"]]} default button [[template:"OK"]]
set [[template:dialogResult]] to display dialog ¬
"[[template:message]]" buttons {[[template:"Cancel", "OK"]]} ¬
default button [[template:"OK"]] ¬
default answer [[template:answer]]
1 change: 1 addition & 0 deletions Script-Debugger/My-Clippings/do shell script.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
do shell script "[[template:theShell]]"
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[[selected-lines:default text]]
-- [[selected-lines:default text]]
(*
[[selected-lines:default text]]
*)
3 changes: 2 additions & 1 deletion Script-Debugger/My-Clippings/error dialog.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
display dialog [[template:errMsg]] & return & return & errNum buttons {"Cancel", "OK"} default button "OK"
display dialog [[template:errMsg]] & return & return & errNum buttons {"Cancel", "OK"} ¬
default button "OK" with icon caution
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
first group of [[template:aList]]

This file was deleted.

1 change: 1 addition & 0 deletions Script-Debugger/My-Clippings/tester.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[template:applicationposix]]
6 changes: 1 addition & 5 deletions Script-Debugger/My-Clippings/text/insert text by paste.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
set the clipboard to [[selection:clipVar]]
tell application "System Events"
tell process "[[template:appName]]"
keystroke "v" using {command down}
end tell
end tell
tell application "System Events" to keystroke "v" using {command down}
2 changes: 1 addition & 1 deletion Script-Debugger/My-Clippings/whose [prop] is|contains.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
whose name is [[template:varname]]
whose name contains [[template:varname]]
Binary file added imgs/km-renumbermacros.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 0d32487

Please sign in to comment.