The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Need basic applescript for changing context (http://forums.omnigroup.com/showthread.php?t=11871)

tah 2009-04-08 01:29 AM

Need basic applescript for changing context
 
I want to change the context of a set of selected tasks as part of my applescript. I can't seem to get it to work though. Any help?

I grab the selected tasks and iterate through them. That all works fine. I cant read the context values, and the context names for each task. But running it backwards to set the context isn't working. Can I set them by context name? to just context IDs?

help

curt.clifton 2009-04-08 04:18 AM

My [URL="http://www.rose-hulman.edu/~clifton/software.html#Await"]Complete and Await Reply[/URL] script includes code for setting the context. You're welcome to lift from there.

tah 2009-04-08 10:34 PM

The section:

set theContextID to id of item 1 of (complete ContextName as context)
set ContextName to first context whose id is theContextID

Not sure I totally understand the first line, what is the "item 1" referring to?

This works mostly. But it doesn't find the context ID for a context name that are a sub-context (i.e. not on a top context)

whpalmer4 2009-04-09 07:31 AM

[QUOTE=tah;58226]The section:

set theContextID to id of item 1 of (complete ContextName as context)
set ContextName to first context whose id is theContextID

Not sure I totally understand the first line, what is the "item 1" referring to? [/QUOTE]

The first entry in the list of completions that is returned by (complete ContextName as context). You can specify a maximum number of matches, but the result still comes back as a list, even if you specified that you only want 1. Here's an example of what is given back:

[code]
tell application "OmniFocus"
complete "Internet" as context
{{xml:"<span class=\"match\">Internet</span>", name:"Internet", score:315, id:"i9xBJiBMtXH"}, {xml:"<span class=\"match\">Internet</span> : iBook G4", name:"Internet : iBook G4", score:210, id:"n6UfiqlB8WX"}, {xml:"<span class=\"match\">Internet</span> : iMac G5", name:"Internet : iMac G5", score:210, id:"bSidHmTsGvc"}, {xml:"<span class=\"match\">Internet</span> : Macbook", name:"Internet : Macbook", score:210, id:"o8ur1eeK1TQ"}, {xml:"<span class=\"match\">Internet</span> : PC", name:"Internet : PC", score:210, id:"m8gFTgpko7G"}}
display dialog 5 buttons {"OK"}
{button returned:"OK"}
end tell
[/code]

curt.clifton 2009-04-09 04:12 PM

[QUOTE=tah;58226]
This works mostly. But it doesn't find the context ID for a context name that are a sub-context (i.e. not on a top context)[/QUOTE]

Unfortunately, you have to climb down the context hierarchy yourself. A subcontext is retrieved like 'context Foo of context Bar'.

fudster 2009-07-30 07:16 AM

[QUOTE=curt.clifton;58175]My [URL="http://www.rose-hulman.edu/%7Eclifton/software.html#Await"]Complete and Await Reply[/URL] script includes code for setting the context. You're welcome to lift from there.[/QUOTE]

Sorry to drift this thread a bit - but -

Curt - I'm using your Complete and Await Reply script (thanks much!) -

How the heck did you add an Icon to the script? I've looked at Script Editor and Googled, and it's eluded me so far.

I want to use an icon for a couple of my home-grown scripts, including my Set Project Dependency script.

fudster 2009-07-30 07:22 AM

hmm, I think I may have found it - simple copy/paste in the .scpt file's infopane?

[url]http://forums.macosxhints.com/archive/index.php/t-26617.html[/url]

curt.clifton 2009-07-30 09:40 AM

Right.

My workflow for script icons is to draw the icons in OmniGraffle, typically very large. Then I export to a png, adjusting the scaling to get a 512x512 image. I drag that image on to a new Icon Composer document to get an icns file. (Icon Composer is installed with the Developer Tools from Apple.) I drop the icns file onto the [URL="http://web.me.com/zweigand/zweisoft/Software/Entries/2009/1/12_IconDroplet_1.2.html"]Icon Droplet[/URL] application to get an "application" file. I can copy from the info. pane of that file and paste onto the info. pane of my script file.

There's probably an easier approach, but this one gets me icons that seem to scale nicely.

fudster 2009-07-30 12:51 PM

Cool, thanks Curt!

Here are a couple of other pages that explain the copy/paste step better. The icon we want to cut/paste is at the *top* of the infopane, not the Preview at the bottom

[URL]http://hubpages.com/hub/How_to_Change_Icons_in_Mac_OS_X[/URL]
[URL]http://pimpmymac.wordpress.com/2007/03/05/how-to-change-icons/[/URL]

My guilt over hijacking this thread for this is too much - I'm going to post this as a new thread.


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

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