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 request - Jump to Project (http://forums.omnigroup.com/showthread.php?t=7998)

gcrump 2008-05-18 07:47 AM

Applescript request - Jump to Project
 
Has anyone written a applescript that will Jump to a specific applescript from either a Launchbar or QS action? What happens to me is that will be in the middle of something else and a thought will occur to me about a particular project. I'd like to pull up launchbar type is a word or two for the project and have a new omnifocus window show up with just this project in it.

Thanks in advance,

George

Craig 2008-05-18 07:54 PM

I have something almost like that working (though not involving AppleScript). I have created OF perspectives that are focused on my folders (which I treat like "areas of responsbility"). So one called "Focused husband," another "focused teacher," etc. They are set to open as new windows.
Because I have added my perspectives directory (~/Library/Application Support/OmniFocus/Perspectives) to my Quicksilver catalog, I can easily pull them up with a couple of keystrokes to review or add stuff.

gcrump 2008-05-20 06:23 AM

Craig,

Thanks for the response, but that won't quite do it for me. I tried. I can write the front end interface to capture the text string of the project and I am a so-so applescripter. If someone could show me even a fragment that will take that string and look for a project that contains that string, it might be all I need to complete it.

Thanks again,

George

Ken Case 2008-05-20 06:42 AM

[QUOTE=gcrump;36856]If someone could show me even a fragment that will take that string and look for a project that contains that string, it might be all I need to complete it.[/QUOTE]

Try something like this:

[CODE]set MyProjectArray to complete ProjectString as project maximum matches 1[/CODE]

You can see this in action in the "Send to OmniFocus" sample script inside the application bundle (OmniFocus.app/Contents/Resources/SampleScripts/Send to OmniFocus.applescript).

Hope this helps!

Craig 2008-05-21 05:20 AM

@ gcrump: if you get this working I hope you share it. It would be one step closer to my fantasy of a [URL="http://forums.omnigroup.com/showthread.php?t=4674"]Quicksilver plugin for OF[/URL].

gcrump 2008-05-21 07:24 AM

@ Craig - Will do.

@ Ken - I'm stuck and have messed with it all morning. Here is what I have, simple no error handling yet. Not much more than what you gave me. I can't figure out how to pull anything from MyProjectArray. In the Result section of script editor it is setting the variable right. For example if I type in "Spotlight" I get:

{{xml:"Customers : Permabit : Permabit <span class=\"match\">Spotlight</span> Article", score:225, id:"hMhoYt5pZ2e", name:"Customers : Permabit : Permabit [B]Spotlight[/B] Article"}}

My assumption is that if I can figure out how to address the array, I can access the ID property and use that to show the Project in a new window. My goal was to add to the script the commands:

set MyProjectID to id of MyProjectArray
set newW to make document window with properties {focus:{MyProjectID}, selected view mode identifier:"project", search term:""}

to the script below. But I get an error on the set MyProjectID statement. If I just use the MyprojectArray in the {focus} I get an error there too...

display dialog "Enter Project to Find" buttons {"Cancel", "Find"} default button 2 default answer "" with title "Project Find"
if button returned of result is "find" then
set ProjectString to text returned of result
tell application "OmniFocus"
set MyDoc to default document
tell MyDoc
set MyProjectArray to complete ProjectString as project maximum matches 1
end tell
end tell
end if


Any help would be appreciated... Thanks.

Ken Case 2008-05-21 08:55 AM

You're almost there! You just need to pull out the id of the first item in the array, then use that id to look up the project. Like this:

[CODE]display dialog "Enter Project to Find" buttons {"Cancel", "Find"} default button 2 default answer "" with title "Project Find"
if button returned of result is "find" then
set ProjectString to text returned of result
tell application "OmniFocus"
set MyDoc to default document
tell MyDoc
set MyProjectArray to complete ProjectString as project maximum matches 1
set MyProjectID to id of first item of MyProjectArray
set ThisProject to project id MyProjectID
set newW to make document window with properties {focus:{ThisProject}, selected view mode identifier:"project", search term:""}
end tell
end tell
end if
[/CODE]

gcrump 2008-05-21 12:12 PM

Getting Closer...
 
Ken,

Thanks for all the help, well and doing most of the work. What I am struggling with now is to make sure I have the filters set correctly. I figured out how to set the sidebar but I want to show all remaining tasks as well. I think I should use either the set (selected task state filter identifier) to "remaining" statement of the available task state filter but both result in an error...

[CODE]display dialog "Enter Project to Find" buttons {"Cancel", "Find"} default button 2 default answer "" with title "Project Find"
if button returned of result is "find" then
set ProjectString to text returned of result
tell application "OmniFocus"
set MyDoc to default document
tell MyDoc
set MyProjectArray to complete ProjectString as project maximum matches 1
set MyProjectID to id of first item of MyProjectArray
set ThisProject to project id MyProjectID
set newW to make document window with properties {focus:{ThisProject}, selected view mode identifier:"project", search term:""}
set (selected smart group identifier of sidebar of newW) to "remaining-projects"
-- set (selected task state filter identifier) to "remaining"
end tell
end tell
end if[/CODE]

Thanks again for all your help!

Ken Case 2008-05-21 01:45 PM

[QUOTE=gcrump;36941]I figured out how to set the sidebar but I want to show all remaining tasks as well. I think I should use either the set (selected task state filter identifier) to "remaining" statement of the available task state filter but both result in an error...[/QUOTE]

Try this:

[CODE]set selected task state filter identifier of content of newW to "incomplete"[/CODE]

Glad I could help!

Craig 2008-05-21 02:40 PM

Very cool! :cool:
I just added an "activate" before the last "end tell"


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

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