This Topic will be updated from time to time with more Macro-Templates
============================================
UPDATED -- Monday, Feb 28th, 2022 -- 15:20 GMT +1
-
another little Markup for this Post
-
Updates to existing Templates (single Modifier ones)
-
Update to Topic Name - reflecting current Template's Versions
-
Added:
- Templates with 2 Modifiers
- Templates with 3 Modifiers
============================================
These Macro-Templates were inspired by the work of Jim (@JMichaelTX) & of
course Dan (@DanThomas) and these Macros:• Jim’s “Trigger Option Using Long Press of HotKey [Example]“
• Dan’s “HotKey Multi-Press Template (Double-Press, Triple-Press, Etc.)“
Hey Folks,
I inverted the wheels and decided going a little bit backwards after I recently found a bug in my Templates.
For all of you who had seen this Topic before and all whose are new to this Topic - I will not give up on the Idea providing these Macro-Templates with Local and Instance Variables - but since this is currently eating more of my Time than I can offer on this task at the time I am writing these words - I'll share them with the usage of Global Variables whose will be deleted at the end of each Template.
ReleaseNotes
MACROS: HotKey Multi-Press Templates (inkl. Long-Press) — Ver 1.2.2
Author : @Nr.5-need_Input
MacroType : Template
Ver : 1.2.2
PURPOSE
These Macro-Templates are for unlimited possibilities using just a single KM Hotkey Trigger with multiple Tappings and an additional hold of the Hot-Key after the last Tap was made.
HOW TO USE
• Just Tap your Hot-Key (for Example 5 times) for what should happen with the “Normal Execution“
• Just do the same and keep holding the Hot-Key the fifth time for other things the Macro should do.
Sounds quite simple - and of course yes - it is simple
Just try and have fun !!
HOW TO SET THESE UP ??!
-
Required:
- Set a single Hot-Key/Shortcut
- Set the Value of hkmplp_InterKeypressDelay
- Set the Value of hkmplp_LongpressDelay
- Set the Value of hkmplp_KeypressCountLimit
- Be sure your Hot-Key/Shortcut Trigger matches in the Long-Press Setup
Every Macro comes with 5 predefined Action-Templates whose are disabled by default (Image below).
Info about these Action-Templates from the Macros:
You can choose any of them based on your Setting of the Variable “hkmplp_KeypressCountLimit“ in the above Group “CUSTOM SETTINGS“
You are free in charge on how you want to implement your Actions in one of the Routines after the green collapsed Comment Actions …. Just be aware to choose the right one for your purposes and of course don’t forget to enable your selected one.
You are even free in charge to preconfigurate new Routines staring from 6 Keypresses to any larger number you want.
The rest is just your Imagination. - Have fun !!!
- Optional:
- Set the Value of DND__hkmplp_UseVerifyingScriptAsFile to 1 (enabled)
- Install the provided ASObjC-Script as compiled Version at a choosen Location and save its Path in the Variable called DND__hkmplp_ScriptPath.
From the dedicated Comment inside the Macros:
!! THESE Variables are needed for the Verifying-SubRoutines in the Long-Press-Setup using AppleScriptObjC !!
The Variable "DND__hkmplp_ScriptPath“ can be used if a locally stored "Compiled Version“ of the ASObjC as "AppleScript-File.scpt“ with the Filename of your chioce is preferred and the Option "DND__hkmplp_UseVerifyingScriptAsFile“ is set to 1 (enabled).
!! IMPORTANT !!
If you decide doing this - keep in mind doing this every Time - otherwise the Path to the compiled script will be lost after the Macro was run.
Also be aware that this Macro gets canceled if you enable the Option "DND__hkmplp_UseVerifyingScriptAsFile“ and leave the Option "DND__hkmplp_ScriptPath“ undefined.
The best option you have in this case is adding the Path to this Template.If not - Just leave "DND__hkmplp_ScriptPath“ AS IS (EMPTY) - DON’T DELETE IT !! - If the Option "DND__hkmplp_UseVerifyingScriptAsFile“ is set to 0 (disabled) the Long-Press-Setup will execute a build in Version of the Script.
The Variable "hkmplp_ScriptResult“ will be empty until the ASObjC runs… It then stores the Output of the Verification-Process.
Here is the ASObjC Code which is used by the Macro-Templates as "Text-Script":
I've migrated the ASObjC - Code to use Properties. You don't have to do do that.
Just copy the Code to Script Debugger or Script-Editor, compile and save.
Click on this to view the Script-Code
use AppleScript version "2.3" -- Mavericks (10.9) or later
use scripting additions
use framework "Foundation"
use framework "AppKit" -- for NSEvent
-- classes, constants, and enums used
property NSControlKeyMask : a reference to 262144
property NSShiftKeyMask : a reference to 131072
property NSAlternateKeyMask : a reference to 524288
property NSFunctionKeyMask : a reference to 8388608
property NSCommandKeyMask : a reference to 1048576
property NSEvent : a reference to current application's NSEvent
-- Defining the output Strings for each Modifier
set fnKeyStr to "Function-Key down : "
set shiftKeyStr to "Shift-Key down : "
set ctrlKeyStr to "Control-Key down : "
set optionKeyStr to "Option-Key down : "
set cmdKeyStr to "Command-Key down : "
-- Function-Key
set fnKeyStat to (((NSEvent's modifierFlags()) div NSFunctionKeyMask) mod 2) > 0
-- Shift-Key
set shiftKeyStat to (((NSEvent's modifierFlags()) div NSShiftKeyMask) mod 2) > 0
-- Control-Key
set ctrlKeyStat to (((NSEvent's modifierFlags()) div NSControlKeyMask) mod 2) > 0
-- Option-Key
set optionKeyStat to (((NSEvent's modifierFlags()) div NSAlternateKeyMask) mod 2) > 0
-- Command-Key
set cmdKeyStat to (((NSEvent's modifierFlags()) div NSCommandKeyMask) mod 2) > 0
-- Generate the current Output as List
set modifierKeyStat to fnKeyStr & fnKeyStat & return ¬
& shiftKeyStr & shiftKeyStat & return ¬
& ctrlKeyStr & ctrlKeyStat & return ¬
& optionKeyStr & optionKeyStat & return ¬
& cmdKeyStr & cmdKeyStat
-- Show the List with the current List
return modifierKeyStat
Here is one Example Macro Image (of a "Single Modifier Template") to give you an idea on how the Templates are build. I post only one Image because they have nearly all the same look.
Downloads - Section
The Templates for "4 Modifiers / Hyper-Key" aren't ready for uploading yet - I am currently working on them. They'll come as soon as possible.
You'll find all other Combinations below - ready for Download and hopefully all without any Issues.
1.) Macro Group: [HKMPLP] HotKey Multi-Press Templates - 1 Modifier (inkl. Long-Press) Ver 1.2.2
Contents: 4 Macro-Templates (one per Modifier-Key)
- [Modifier ⇧] HotKey Multi-Press Template - one Modifier (inkl. LongPress) -- Ver 1.2.2
- [Modifier ⌃] HotKey Multi-Press Template - one Modifier (inkl. LongPress) -- Ver 1.2.2
- [Modifier ⌘] HotKey Multi-Press Template - one Modifier (inkl. LongPress) -- Ver 1.2.2
- [Modifier ⌥] HotKey Multi-Press Template - one Modifier (inkl. LongPress) -- Ver 1.2.2
Macro-Group-File:
2.) Macro Group: [HKMPLP] HotKey Multi-Press Templates - 2 Modifiers (inkl. Long-Press) Ver 1.2.2
Contents: 6 Macro-Templates (one per Modifier Combination)
- [Modifiers ⇧⌃] HotKey Multi-Press Template - two Modifiers (inkl. LongPress) -- Ver 1.2.2
- [Modifiers ⇧⌘] HotKey Multi-Press Template - two Modifiers (inkl. LongPress) -- Ver 1.2.2
- [Modifiers ⇧⌥] HotKey Multi-Press Template - two Modifiers (inkl. LongPress) -- Ver 1.2.2
- [Modifiers ⌃⌘] HotKey Multi-Press Template - two Modifiers (inkl. LongPress) -- Ver 1.2.2
- [Modifiers ⌃⌥] HotKey Multi-Press Template - two Modifiers (inkl. LongPress) -- Ver 1.2.2
- [Modifiers ⌥⌘] HotKey Multi-Press Template - two Modifiers (inkl. LongPress) -- Ver 1.2.2
Macro-Group-File:
3.) Macro Group: [HKMPLP] HotKey Multi-Press Templates - 3 Modifiers (inkl. Long-Press) Ver 1.2.2
Contents: 3 Macro-Templates (one per Modifier Combination)
- [Modifiers ⇧⌃⌘] HotKey Multi-Press Template - three Modifiers (inkl. LongPress) -- Ver 1.2.2
- [Modifiers ⇧⌃⌥] HotKey Multi-Press Template - three Modifiers (inkl. LongPress) -- Ver 1.2.2
- [Modifiers ⌃⌥⌘] HotKey Multi-Press Template - three Modifiers (inkl. LongPress) -- Ver 1.2.2
Macro-Group-File:
The Macros were uploaded in a DISABLED state. You must enable them before you can use them.
License/Disclaimer (MIT)
Copyright (c) 2021-2022 Tobias Zittlau
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.