PDA

View Full Version : script to set window to inbox?


Craig
2007-09-15, 08:10 PM
I'm loving the new scriptability to move to perspectives, e.g.

tell application "OmniFocus"
tell default document
tell front document window
set perspective name to "waitingfor"
end tell
end tell
end tell

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)

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

Craig
2007-09-17, 05:10 AM
Ah, of course. Thanks a bunch for the idea!

Tim Wood
2007-09-18, 10:43 PM
Now my question is this: Is there a way to tell the front document window to go to the inbox?

Yep! ...


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

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.


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


Thank you Tim for the original code.