The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   script to set window to inbox? (http://forums.omnigroup.com/showthread.php?t=4879)

Craig 2007-09-15 08:10 PM

script to set window to inbox?
 
I'm loving the new scriptability to move to perspectives, e.g.

[CODE]tell application "OmniFocus"
tell default document
tell front document window
set perspective name to "waitingfor"
end tell
end tell
end tell[/CODE]

Now my question is this: Is there a way to tell the front document window to go to the inbox?

Lutin 2007-09-16 03:10 PM

There might be a way to script it natively, but you can emulate the shortcut with System Events (you need GUI Scripting enabled)

[code]activate application "OmniFocus"
tell application "System Events"
tell process "OmniFocus"
keystroke "1" using {command down, option down}
end tell
end tell[/code]

Craig 2007-09-17 05:10 AM

Ah, of course. Thanks a bunch for the idea!

Tim Wood 2007-09-18 10:43 PM

[QUOTE=Craig;21199]Now my question is this: Is there a way to tell the front document window to go to the inbox?[/QUOTE]

Yep! ...

[code]
tell application "OmniFocus"
tell front document window of default document
set selected view mode identifier to "project"
tell sidebar to select inbox
end tell
end tell
[/code]

Lutin 2007-09-18 11:50 PM

Note that the answer of Tim Wood is better:
- it doesn't need to have GUI scripting enabled
- it doesn't rely on shortcut, which can be changed
- it's a cleaner code :p

Thank you Tim

Lutin 2007-09-19 12:14 AM

I use this script during my reviews, and a few times throughout the day.

Sometimes, I closed the last window of OmniFocus, and the script won't work.

Here is an improved version that should take care of this.

[code]
tell application "OmniFocus"

tell default document
if number of document window is 0 then
make new document window with properties {bounds:{0, 0, 500, 500}}
end if
end tell

tell front document window of default document
set selected view mode identifier to "project"
tell sidebar to select inbox
end tell
end tell
[/code]

Thank you Tim for the original code.


All times are GMT -8. The time now is 12:04 AM.

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