Scripting Menu selection fails
The following script snippet works fine from script editor, but fails when run as a toolbar script with an error referencing menu bar 1, and just does nothing when run from the script menu.
Any ideas? (its part of a larger script - but its the problem part). Is this something with the tell block of scripts running within the OF context? [CODE]tell application "OmniFocus" activate tell application "System Events" to tell process "OmniFocus" click menu item "Move Up" of menu 1 of menu item "Move" of menu 1 of menu item "Outlining" of menu 1 of menu bar item "Edit" of menu bar 1 delay 0.05 end tell end tell[/CODE] -P |
I'd guess the "activate" line is what's screwy. See [URL="http://forums.omnigroup.com/showthread.php?t=5141"]this thread[/URL].
|
You can comment out the activate and the problem persists.
Its that there doesn't seem to be any menubars exposed in this context. This script displays 1 when run from the script editor, but 0 when run as a toolbar script. [CODE]tell application "OmniFocus" tell application "System Events" to tell process "OmniFocus" set x to every menu bar set y to (count of x) end tell end tell display dialog y[/CODE] -P |
This works for me from the system script menu, but fails from a toolbar item, as you note. Not sure why yet.
|
Looking at this, my guess is that because OmniFocus is sending AppleEvents when running the script from the toolbar, it is busy doing its own thing when the system events process tries to ask it to perform UI actions.
Some of the other scripting support has 'suspend' support, but NSAppleScript doesn't... so fixing this looks like it might be relatively hard (at least I don't know the trick right off the top of my head). |
Tim, thanks for even taking the time to look at this during the deadline crunch!
-Preston |
All times are GMT -8. The time now is 10:42 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.