The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   AppleScript to force inbox clean up (http://forums.omnigroup.com/showthread.php?t=15477)

cerithom 2010-03-03 12:37 AM

AppleScript to force inbox clean up
 
Looking for a way to tell OF to "Clean Up" the inbox without switching focus to the application.

Got a mail rule which assigns contexts, projects, due dates but will only place the task in the inbox requiring a final step to switch to OF and cmd+K.

Fussy yes I am but any ideas?

Tried the:

tell application omnifocus
compact front document
end tell

but it causes Of and mail to hang and then fail.

Thanks for any help,

C

RobTrew 2010-03-03 02:06 AM

[QUOTE=cerithom;74214]Got a mail rule which assigns contexts, projects, due dates but will only place the task in the inbox
Tried the:

tell application omnifocus
compact front document
end tell

but it causes Of and mail to hang and then fail.[/QUOTE]

First, a silly question, just in case ...

Do you have the required double quotes around the application identifier, as in:

[COLOR="Navy"]tell application [/COLOR]"OmniFocus"[INDENT][COLOR="navy"]compact front document[/INDENT]end tell[/COLOR]

or

[COLOR="Navy"]tell application id[/COLOR] "com.omnigroup.OmniFocus"[INDENT][COLOR="navy"]compact front document[/INDENT]end tell[/COLOR]

If you do, what does the mail rule code look like ? You will need to slip a [COLOR="navy"]compact[/COLOR] command in there somewhere ... (Probably just after the document makes a new task and sets its properties).

cerithom 2010-03-03 04:51 AM

Yes I do have the quotes in there.

Sorry it was a quick typed post rather than a copy paste from AppleScript.

tell application "System Events"
keystroke "C" using {command down, shift down, option down}
end tell

tell application "OmniFocus"
compact front document
end tell

Console message says: 03/03/2010 13:44:16 Mail[500] rejected messages (rule Digidelivery Posted), count 1

03/03/2010 13:46:17 OmniFocus[280] Presenting modal error: {
code = 2131;
domain = "com.omnigroup.OmniFocus";
userInfo = {
NSLocalizedDescription = "The script handler failed.";
NSLocalizedRecoverySuggestion = "Errors returned from handler <ScriptHandler:0x8b5cf20 com.omnigroup.OmniFocus.ScriptHandler.Mail_with_MailTags NSBundle </Applications/Omnifocus 1.8/OmniFocus.app/Contents/PlugIns/BuiltInClippingHandlers.plugin> (not yet loaded)>: {\n NSAppleScriptErrorAppName = Mail;\n NSAppleScriptErrorBriefMessage = \"AppleEvent timed out.\";\n NSAppleScriptErrorMessage = \"Mail got an error: AppleEvent timed out.\";\n NSAppleScriptErrorNumber = -1712;\n NSAppleScriptErrorRange = NSRange: {2552, 9};\n}";
"com.omnigroup.framework.OmniBase.ErrorDomain.FileLineAndNumber" = "/Volumes/Local/Users/Shared/omnibuild/ReleaseProduct/Source/OmniGroup/Applications/OmniFocus/App/AppleScript/ScriptHandler.m:405";
};
}

If that means anything?>?

RobTrew 2010-03-03 07:19 AM

Not quite sure what the context of the keystroke is, or how you are launching the script, but something for Omni, I think.

I would try OmniFocus > Help > Send feedback

cerithom 2010-03-03 08:23 AM

Keystroke is called from a Mail rule to "Send clipping to Omnifocus" and that's my key-combo for that Service.

That combined with MailTags is what enables the email to be sent to OF's inbox in the first place.

Thank you for your help but as it stands the thread with Omni had drawn a blank.

C

Brian 2010-03-03 01:08 PM

I'm pretty sure clippings are always sent to the default document (which may not be in front).

Does the script work using default document instead of front document?

The (trivial) example below ran w/out complaint on my machine, FWIW.

[CODE]tell application "OmniFocus"
tell default document
compact
end tell
end tell[/CODE]

cerithom 2010-03-05 03:58 AM

Brian,

Thank you very much that did the job.

Much appreciated.

C


All times are GMT -8. The time now is 08:42 AM.

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