Hi All,
For various reasons I want to make a macro for a quite big list of commands where the key stroke action and the hotkey trigger are one in the same and the name of the macro would just be a descriptive version of the command. I have a numbers spreadsheet with 3 columns outlining it all and I;'ve also saved each one of those to a separate txt file and comma separated csv.
I got chatGPT to convert all the commands to their short form (with symbols for command and etc) and export a kmmacros file for me but when I'm import it, the actual keystroke part of each command isn;t there. I think something to do with how XML is defined or UUID is created etc. anyway -
I decided to simply make a macro that would create a new macro, name, insert action keystroke, then mimic the keystroke,.... then I stopped, and decided this doesn't feel like a good idea, hot key trigger the same as the keys stroke it's triggering?... doesn't sound good to me.
Can someone help and tell me how I can achieve this?
One way to batch create a bunch of similar macros is something like done in this macro:
However note that creating a hot key trigger requires knowing the keycode rather than the key, so that may be an issue for you. You can likely find a table mapping ASCII keys to key codes online, as the keycodes are standard for most english keyboard.
hi Peter,
I have already converted the descriptive commands, below is a picture of what I'm dealing with so you can see. Your way above is interesting and also, very involved, I was hoping it would be a bit easier than that. I made a macro to make the macros using KM itself which worked increadably well apart from when I go to specify a key stroke on the add key stroke command. Of course, I can't type something like Option+K in this circumstance, and I can paste it cause that would just end up ⌘V on every one. although, what you've given me above seems to do that.
Try again but, as Peter said, using the keycode for the the key, not the letter. You may have to adjust for your language/layout, but you'll find a good starting reference at Complete list of AppleScript key codes.
If you want to try a different way, could you post the macro that should be created by row 1 of your image? That'll give people something more definite to aim at.
An example of what the outcome I'd like is attached. Simply a name for the macro and a corresponding keystroke (no actual trigger is needed) with the later being the thing I don't know how to do. I've got the entire list saved in a few columns with the description, shortcut key, and key codes would need to be.
You said you could already create macros via XML, except the keystroke wasn't there. Use the codes instead, converting to decimal first -- so A would be 0, B would be 11, etc. You'll also have to work out how to do the modifiers -- manually create some modified keystrokes, copy the action's XML, paste into your text editor, and you should soon spot the pattern.
I should explain, I got chatGPT to do it which most of the time is a downright waste of time but surprisingly, it did a good job on this occasion, however when importing them into KM, something weird (to me) happens. I can see the correct codes written into the code of each macro but it gets stripped out when it's read in. I also tried the key codes (I use an app called 'Key Code' highly recommend it) but then KM refuses to read it in at all. hence why I started down the make macro's for macros inside KM natively.
I tried that last advice with the text expansion and got that to work so to speak (thank you) but the app at the other end expects the commands to be keystrokes which need to more or less arrive at the same time ie ⌘K is being interpreted as ⌘ then K, which is why I really want to populate the keystroke command instead, but not sure if thats possible. I note you can also invoke commands via menu's which is cool but emulating all the commands in each menu would be to much.
The macro that creates text expansions shows you how to manipulate the XML to produce what KM expects, and how to import it. You have to change the XML to do what you want, swapping out the code for expansions for the XML for your simulated keystroke commands.
Here's one closer to what you want. This will work as-is for a US/UK standard or extended keyboard -- including function keys, arrows, the number pad...
I've left the complete list of US key codes in the first action. You should change your input file to match those and the format used in your picture -- so if you've eg Command and the Return key as the simulated keystroke it should be on your list as "Command+Return".
You'll need to export your command list as a tab-delimited file (which also allows you to use , as a keystroke) with 3 columns: macro Group, macro name, and keystroke:
Add Track Add Track... T
Audio Adjust Fades to Range A
Audio Auto-Grid Shift+Q
Audio Crossfade X
...
While there's only addition of macros, no changing or deletion, it would still be good to backup everything first!
Run the macro, select your tab-delimited list, sit back... You might want to try a small set first, just in case -- I've tested as much as I can, but I'm sure something will have slipped through.
Thank you, is there anyway I can test it all within a folder on the far left or some soft or one shot tag or a second blank instance of KM etc? problem is, cuirass I've tried many things some of which are still relevant its kind of hard for me to check/ see what's new all the time.
If you change your list so that the macro Groups to use are "test_Add Track", "test_Audio", or similar it'll make new Groups with those names, making it easy for you to see what happens.