Hello, I’m writing a script using python API which is working wonderfully. This allows me to find and open new project tasks. However, once I have a found the project task, I would like to automatically open the task in the Mac app. I’ve used Applescript to do this in other applications, but not finding anything on how to do this for the Asana app. Is Applescript not supported with Asana? Is there another way to automate this?
I’m not interested in doing this via a browser…I want it to use native Asana app.
Unfortunately, the native Asana app is not so native to macOS. It’s developed on Electron and it’s basically the Asana web app wrapped in a Chromium/Node.js shell. That’s why it cannot support AppleScript - it doesn’t implement the macOS accessibility/scripting infrastructure that AppleScript relies on.
However, I believe for this scenario you can just use OS-level feature for custom URL scheme and open any necessary task using asanadesktop:///app/0/{project_gid}/{task_gid} expression in Apple Script (with open location) or just in Python (with subprocess.run).
Thanks Alexander, I got that to work but when I call python webbrowser.open_new_tab(url) where url=“asanadesktop://app/1/<project_gid>/<task_gid>” it doesn’t really do anything. If I change the url=“https://google.com” it opens this. Any ideas on why python webbrower doesn’t like asanadekstop url?
I think it’s because webbrowser in Python is designed to work with web browsers directly. It doesn’t know anything about custom URL schemes like asanadesktop:///, which are on OS-level.
Use subprocess.run(["open", url]) instead — that goes through macOS itself, which knows where to send any other than the standard URL scheme.
Sorry, my explanation was wrong - webbrowser works fine as well and understands custom URLs. Looks like the issue was with the URL format you try to use. Two things to fix:
:// should be :/// (three slashes)
/1/ should be /0/
The working URL format I tested is asanadesktop:///app/0/{project_gid}/{task_gid}.