Hi Everyone,
I am trying to make an Alfred workflow that does the following
1. Is triggered via a keyboard shortcut
2. Takes the currently selected text as input
3. Feeds that text into a Python script to do some basic processing (removing spaces, changing capitalization, etc)
4. Pastes that modified text in place of the selected text
Based on the above requirements, I do not think the script filter tool will work well because that requires calling up Alfred's dialog box, but I am having trouble outputting the result of the Python script into something Alfred can work with. I have tried different Python outputs, including the `sys.stdout.write` recommended on other forums. The current Python script (no processing, just testing) in which I tried to use a JSON object is below. I believe JSON objects are only for script filters though, and the return line also appears to do nothing helpful.
import sys
import json
items = {
"type": "text",
"title": "Result",
"arg": "Test_Text"
}
sys.stdout.write(json.dumps(items))
return json.dumps(items)
Is there an easy way to get Alfred to read the Python output, or a different way to achieve what I want. I would prefer Python to do the heavy lifting even though the script is simple because it's just more portable, but a working script is better than nothing obviously. Thanks for your help. Workflow and clipboard modules attached.