The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Scripting Menu selection fails Thread Tools Search this Thread Display Modes
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
-P
 
I'd guess the "activate" line is what's screwy. See this thread.
 
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

-P
 
This works for me from the system script menu, but fails from a toolbar item, as you note. Not sure why yet.
__________________
CTO, The Omni Group
 
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).
__________________
CTO, The Omni Group
 
Tim, thanks for even taking the time to look at this during the deadline crunch!

-Preston
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Context (Selection) to Home menu ? Tado OmniFocus for iPhone 0 2012-04-16 03:42 PM
OW crashing on contextual menu selection Chrysippus OmniWeb General 3 2009-06-23 05:37 PM
Export issue / Modify the selection in a Document via AppleScript / Scripting Bridge Scifer_2008 OmniGraffle General 0 2008-10-08 06:06 AM
Fails with MSN-Hotmail dru OmniWeb Bug Reports 6 2007-03-15 08:30 AM
AudioHijackPro (2.6.7) fails with SP 17 jpmeia OmniWeb Bug Reports 8 2006-07-20 08:13 PM


All times are GMT -8. The time now is 06:56 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.