Jump to content

YuTang

Member
  • Posts

    24
  • Joined

  • Last visited

  • Days Won

    1

YuTang last won the day on July 1 2023

YuTang had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

YuTang's Achievements

Member

Member (4/5)

5

Reputation

  1. Thank you for your reply! Finally I solve it myself, now I use a simple AppleScript. tell application "OmniFocus" set theQuery to "atlviq9dkBl" tell default document set theTask to task id theQuery set taskName to name of theTask set taskNote to note of theTask set encodedTaskName to my urlEncode(taskName) set encodedTaskNote to my urlEncode(taskNote) end tell end tell set resultText to encodedTaskName on urlEncode(str) local str try return (do shell script "/bin/echo " & quoted form of str & ¬ " | perl -MURI::Escape -lne 'print uri_escape($_)'") on error eMsg number eNum error "Can't urlEncode: " & eMsg number eNum end try end urlEncode set bluebirdLink to "bluebird://add?title=" & encodedTaskName & "&notes=" & encodedTaskNote open location bluebirdLink Actually, I tried an AppleScript like this at the very beginning, yet I name the variable bluebirdLink as url, which strangely cause an error: Can’t set URL to "bluebird://add?title=" & encodedTaskName & "&notes=" & encodedTaskNote. Access not allowed. after I changed it, it's now ok. Thank you again!~!
  2. I think the problem might be const _task = app.Task({id: theQuery, in: defaultDoc}); does not actually fetch the proper task with the given id. So I wonder if there is any way to get the metadata of OmniFocus tasks needed via their id. Do need your help🥹.
  3. Thank you for your replied, I've adjusted them, yet it still doesn't work.
  4. I change it a little(as is shown in the following), and now the debug info is: ERROR: 1-Search OmniFocus JS[Run Script] execution error: Error: ReferenceError: Can't find variable: URL (-2700) const app = Application('OmniFocus'); app.includeStandardAdditions = true; // Get metadata of the selected task const defaultDoc = app.defaultDocument; const theQuery = '{query}'; const _task = app.Task({id: theQuery, in: defaultDoc}); const taskName = _task.name; const taskNote = _task.note; // Add task in a pomodoro app called Bluebird and begin working session const url = "bluebird://add?title=" + encodeURIComponent(taskName) + "&notes=" + encodeURIComponent(taskNote); url = URL.fromString(url); url.open(); Actually, I'm not that familiar with coding, so do need your help!
  5. ps: I have already adjusted the language from /usr/bin/osascript to /bin/bash!
  6. I made some minor adjustments to the script based on rhydlewis/alfred-search-omnifocus: An Alfred workflow that runs free text searches on OmniFocus data (github.com) to fit my own workflow. I want to use this script to retrieve metadata of the selected task(such as task name, project name, due date, notes, tags, etc.) from the list of matching results and then to set a timer in a pomodoro app called Bluebird using these metadata. Initially, my script looked like this: const app = Application('OmniFocus'); app.includeStandardAdditions = true; // Get metadata of the selected task const defaultDoc = app.defaultDocument; const theQuery = '{query}'; const _task = app.Task({id: theQuery, in: defaultDoc}); const taskName = _task.name; const taskNote = _task.note; // Add task in a pomodoro app called Bluebird and begin working session const url = "bluebird://add?title=" + encodeURIComponent(taskName) + "&notes=" + encodeURIComponent(taskNote); app.openLocation(url); However, I quickly found out that OmniFocus cannot open URL schemes that don't start with "omnifocus." Therefore, I came up with a plan B: I can just try to pass the variables $taskName and $taskNote from the script and append an Alfred action to open the URL: bluebird://add?title={var:taskName}&notes={var:taskNote}. However, since I'm not familiar enough with Alfred, I don't know how to adjust the script to pass the variables. Here is the adjusted script based on the suggestion from ChatGPT: # Get task name and task note from OmniFocus using JXA (JavaScript for Automation) taskName=$(osascript -l JavaScript -e ' var app = Application("OmniFocus"); app.includeStandardAdditions = true; var defaultDoc = app.defaultDocument; var theQuery = "{query}"; var _task = app.Task({id: theQuery, in: defaultDoc}); var taskName = _task.name; taskName; ') taskNote=$(osascript -l JavaScript -e ' var app = Application("OmniFocus"); app.includeStandardAdditions = true; var defaultDoc = app.defaultDocument; var theQuery = "{query}"; var _task = app.Task({id: theQuery, in: defaultDoc}); var taskNote = _task.note; taskNote; ') # Store these values in Alfred's workflow environment variables echo "{ \"alfredworkflow\" : { \"variables\" : { \"taskName\" : \"$taskName\", \"taskNote\" : \"$taskNote\" } } }" Sadly, it just did not work. It would be highly highly appreciated if you could please help me out!
  7. I do follow the instructions, but the situation is still the same, and I have no idea what's the problem, omg [13:44:43.091] Google Similar Images[Run Script] Processing complete [13:44:43.093] Google Similar Images[Run Script] Passing output '' to Open URL [13:45:52.535] Google Similar Images[File Action] Processing complete [13:45:52.544] Google Similar Images[File Action] Passing output '/Users/yutang/Documents/Global Inbox/Universal Search Workflow_Icon.png' to Run Script [13:45:52.545] Google Similar Images[File Action] Passing output '/Users/yutang/Documents/Global Inbox/Universal Search Workflow_Icon.png' to Post Notification [13:47:07.681] ERROR: Google Similar Images[Run Script] uploading u'/Users/yutang/Documents/Global Inbox/Universal Search Workflow_Icon.png' to Google ... cmd=['/usr/bin/curl', '--include', '--silent', '--user-agent', 'alfred-similiar-image-search 0.1 ()', '--form', 'image_url=', '--form', 'filename=', '--form', 'h1=en', '--form', 'bih=179', '--form', 'biw=1600', '--form', 'encoded_image=@/Users/yutang/Documents/Global Inbox/Universal Search Workflow_Icon.png', 'https://www.google.com/searchbyimage/upload'] Traceback (most recent call last): File "url_for_image.py", line 95, in <module> sys.exit(main()) File "url_for_image.py", line 88, in main url = similar_images_url(filepath) File "url_for_image.py", line 68, in similar_images_url output = subprocess.check_output(cmd) File "/Users/yutang/.pyenv/versions/2.7.18/lib/python2.7/subprocess.py", line 223, in check_output raise CalledProcessError(retcode, cmd, output=output) subprocess.CalledProcessError: Command '['/usr/bin/curl', '--include', '--silent', '--user-agent', 'alfred-similiar-image-search 0.1 ()', '--form', 'image_url=', '--form', 'filename=', '--form', 'h1=en', '--form', 'bih=179', '--form', 'biw=1600', '--form', 'encoded_image=@/Users/yutang/Documents/Global Inbox/Universal Search Workflow_Icon.png', 'https://www.google.com/searchbyimage/upload']' returned non-zero exit status 28
  8. I'm so sorry, it's until now that I made sense of that, thank you once again ww
  9. Its download page is here: https://github.com/deanishe/alfred-similar-image-search
  10. Thanks to the help of Vitor, I finally got a new version of it that seemed to work on my new Mac without python2. But it still doesn't work properly, and the error info is here: [16:13:57.670] Logging Started... [16:14:12.232] Google Similar Images[File Action] Processing complete [16:14:12.235] Google Similar Images[File Action] Passing output '/Users/yutang/Documents/Global Inbox/CleanShot_2022-08-04_16.06.54@2x.png' to Run Script [16:14:12.236] Google Similar Images[File Action] Passing output '/Users/yutang/Documents/Global Inbox/CleanShot_2022-08-04_16.06.54@2x.png' to Post Notification [16:14:12.415] ERROR: Google Similar Images[Run Script] uploading u'/Users/yutang/Documents/Global Inbox/CleanShot_2022-08-04_16.06.54@2x.png' to Google ... cmd=['/usr/bin/curl', '--include', '--silent', '--user-agent', 'alfred-similiar-image-search 0.1 ()', '--form', 'image_url=', '--form', 'filename=', '--form', 'h1=en', '--form', 'bih=179', '--form', 'biw=1600', '--form', 'encoded_image=@/Users/yutang/Documents/Global Inbox/CleanShot_2022-08-04_16.06.54@2x.png', 'https://www.google.com/searchbyimage/upload'] Traceback (most recent call last): File "url_for_image.py", line 95, in <module> sys.exit(main()) File "url_for_image.py", line 88, in main url = similar_images_url(filepath) File "url_for_image.py", line 68, in similar_images_url output = subprocess.check_output(cmd) File "/Users/yutang/.pyenv/versions/2.7.18/lib/python2.7/subprocess.py", line 223, in check_output raise CalledProcessError(retcode, cmd, output=output) subprocess.CalledProcessError: Command '['/usr/bin/curl', '--include', '--silent', '--user-agent', 'alfred-similiar-image-search 0.1 ()', '--form', 'image_url=', '--form', 'filename=', '--form', 'h1=en', '--form', 'bih=179', '--form', 'biw=1600', '--form', 'encoded_image=@/Users/yutang/Documents/Global Inbox/CleanShot_2022-08-04_16.06.54@2x.png', 'https://www.google.com/searchbyimage/upload']' returned non-zero exit status 7 [16:14:12.424] Google Similar Images[Run Script] Processing complete [16:14:12.425] Google Similar Images[Run Script] Passing output '' to Open URL As I actually have no knowledge of programming, I can't make sense of it and have no idea what the problem is. I would highly highly appreciate it if you could please help me about this! ❤️
  11. So what's on earth the problem with my installation of python2, or if there is no problem, why I'm still prompted "/bin/bash: line 2: /usr/bin/python: No such file or directory" when I attempt to use workflows that rely on python2?
  12. Also I like the Star Ratings workflow very much, it seems that it also relies on python 2. As forI've switched to the new version of OmniFocus workflow, thank you so much!
  13. I make a workflow to pass through selection/clipboard contents(only if there is no selection) to Alfred (for example, to search them on a certain website), they can be texts or images, yet I have no idea how to filter them from each other for different usages. Could you please give me any instruction on this, thank u so so much~
  14. Yeah, I would like to use a workflow named google similar images, its bundle id is here: net.deanishe.alfred-google-similar-images
×
×
  • Create New...