I'm trying to set up a macro that allows me to quickly access clipboard items I use frequently. I need a list of constants (either one-word strings, could be numbers or even full sentences). Similar to named clipboards in Keyboard Maestro.
Example clipboard items:
- VAT Number 1234567
- Company Reg number 123456789
- Address: 12 Road Name, Suburb, Country 1234
What I want to do is use a keyboard shortcut to trigger a window or pop-up that asks me to choose one of the items (ideally the window would be where the mouse is, but not essential!), and once I've selected an item either by clicking on it or using the arrow keys and return, then the text is typed/pasted into whichever application is currently active.
Workflow example:
- Press hotkey trigger
- Make selection of named clipboard item
- The selected text item is typed into the active app.
Linked from:
- AAndrew Sherman @Andrew_Sherman
I'm trying with the following actions:
- Select from list
- Type text
But I'm getting an error "expected string but got object"
Christian Scheuer @chrscheuer2021-02-02 14:44:42.614Z
Hi Andrew,
The following script should do the trick:
//Define the text items var items = [ { name: 'VAT Number', value: '1234567' }, { name: 'Company Reg number', value: '123456789' }, ]; //Record which app is focused var activeAppBundleID = sf.ui.frontmostApp.activeBundleID; //Ask the user which item to use var selectedItem = sf.interaction.popupSearch({ items: items, title: 'Please select an item to copy', }).item; //Re-activate the originally focused app sf.ui.app(activeAppBundleID).appActivate(); //Type the text sf.keyboard.type({ text: selectedItem.value });
- AAndrew Sherman @Andrew_Sherman
Perfect, thank you.