I am not a programmer but managed to create a python script that takes an identifier (string) as an input, calls an API, gets some data and formats it as another string I paste into my work.
I run the script from terminal. It requires navigating to the script’s directory first and copying the output manually.
How could I trigger some GUI input window for my identifier, run the script in the background and get the resulting string directly into my clipboard?
I have LaunchBar and Keyboard Maestro, both should be capable of such functionality, but I failed repeatedly to set it up.
I think you might be able to do this in Shortcuts.
I’m sharing an example of a Shortcut I recently created, in case it contains any helpful ideas for you: Random Unsplash Photo and info.
I suspect you’d need to ask for your input as text, then include that variable in your string.
What I’ve been finding as I’ve been learning Shortcuts is that the code to do something in Shortcuts will have more steps than Python or JavaScript would use to do the same job, but it can do it for the kinds of things you’re talking about. And there’s a bonus, if it matters at all to you: unlike Python and JavaScript, those Shortcuts will also run on iOS and iPadOS.
Here’s a Keyboard Maestro macro that does what you want. Of course you’ll want to change the prompts and the script name (note that you probably have to put in the whole path for the script, as I have done).