Hi all, I’m having some trouble trying to refocus the Sublime Text window from within a plugin. Note, I’m doing this on macOS, which might be all of the problem!
The context is that I’m using a plugin to call out to a local web API, which in turn activates a GUI that retains window focus after the task is completed. This is the Zotero Better Bibtex CAYW API for those that are curious.
Generally, my query is, what would be the best way to do this?
Specifically, I’m having some trouble with my first attempt, which was to run a subprocess
to call the macOS
osascript
utility, which is just a way to run code in Apple’s AppleScript language intended for automation and whatnot.
For example, on the command line in macOS: osascript -e 'activate application "Sublime Text"'
will bring Sublime into focus nicely.
Running this through python’s subprocess
module (with subprocess.check_output()
for instance) works just fine too. But from within Sublime’s plugin runtime or the console, Sublime hangs for about 30 seconds and then returns an error from check_output()
.
Any thoughts on what might be going on here?
Sublime Version: 4120