The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Please help finish a script to launch Minuteur with a task's estimated time (http://forums.omnigroup.com/showthread.php?t=4748)

smew 2007-09-03 07:17 PM

Please help finish a script to launch Minuteur with a task's estimated time
 
I have been working on a script (attached) to select a task and then launch a Minuteur countdown with that task's estimate time.

However, I run into this problem: OmniFocus returns the estimated time as an integer stating the number of minutes the estimated task will take. Minuteur only accepts for countdown 6-digit inputs in the form of HHmmss.

Any help on how to tell AppleScript to transform data from one format to the other into the other will be very appreciated!

Thanks!

smew 2007-09-05 06:32 AM

Script attached (again)
 
1 Attachment(s)
It looks like the previous post lost the script attached. Trying again: both attached and [URL="http://www.mediafire.com/?9uxb4o91or9"]here[/URL].

RobTrew 2007-09-05 09:30 AM

That's an interesting idea.

You could experiment with something like this, for example:

[CODE]-- For Example 4027 remaining minutes
set TotalMins to 4027

-- Build a six digit string
set strHoursLeft to (TotalMins div 60) as string
if length of strHoursLeft < 2 then
set strHoursLeft to "0" & strHoursLeft
end if

set strAdditionalMins to (TotalMins mod 60) as string
if length of strAdditionalMins < 2 then
set strAdditionalMins to "0" & strAdditionalMins
end if

set strMinuteur to strHoursLeft & strAdditionalMins & "00"

[/CODE]

RobTrew 2007-09-07 03:29 PM

A simplified script with minimal messages might look like:

[CODE]tell application "OmniFocus"
tell front document
tell document window 1
set oTrees to selected trees of content
if length of oTrees > 0 then
set oTask to value of first item of oTrees
set lngMinutes to estimated minutes of oTask
if lngMinutes > 720 then
display dialog "Maximum Minuteur period is 12 hours"
else
try
if lngMinutes is missing value then
else
set strHMS to my MinuteurString(lngMinutes)

tell application "Minuteur"
activate
StartCountdown strHMS
end tell
end if
end try
end if
end if
end tell
end tell
end tell


on MinuteurString(lngMinutes)
set strHoursLeft to (lngMinutes div 60) as string
if length of strHoursLeft < 2 then
set strHoursLeft to "0" & strHoursLeft
end if

set strAdditionalMins to (lngMinutes mod 60) as string
if length of strAdditionalMins < 2 then
set strAdditionalMins to "0" & strAdditionalMins
end if

return strHoursLeft & strAdditionalMins & "00"
end MinuteurString[/CODE]

smew 2007-09-11 03:42 PM

Rob -

Thanks so much for taking this up! I was not online last week. However, I can't get the script to do anything more than just activate Minuteur...

RobTrew 2007-09-11 09:04 PM

[QUOTE=smew;20966] I can't get the script to do anything more than just activate Minuteur...[/QUOTE]

If you are getting Applescript error messages then you may need to ask the author for Minuteur 5.

Otherwise, I did have intermittent success with an earlier build of OF, but the most recent build seems to be OK.

smew 2007-09-15 03:43 PM

No, no error messages. I was waiting to get a recent version of OF, but this doesn't change anything. Minuteur is activated, but the time is not changed and a countdown does not begin.

I keep looking at the script and can't imagine where the problem might be. Thanks so much anyway, Rob!

curt.clifton 2007-09-15 04:56 PM

smew,

I haven't tried the script. But one tip is to run the script in Script Editor. If you launch a script from within OF, any errors are silently swallowed. From Script Editor, you'll get the error message.

Craig 2007-09-15 08:14 PM

[QUOTE=RobTrew;20973]Minuteur 5[/QUOTE]

What's that? Or should I say Qu'est-ce que c'est?

RobTrew 2007-09-15 09:59 PM

The problem is unlikely to be in the script itself, which I am using on my own system without a problem.

It did not, however, work with [URL="http://www.phg-home.com/index_mac.html"]Minuteur 4[/URL], which seemed to have some kind of applescript problem, so I do recommend that you [URL="mailto:%70%68%67%61%6C%6D%65%6C%40%77%61%6E%61%64%6F%6F%2E%66%72?Subject=%41%20%70%72%6F%70%6F%73%20%64%65%20%74%6F%6E%20%73%69%74%65%2E%2E%2E"]write to the author[/URL] and ask for version 5. (No need to write in French, if that is deterring you :-)


All times are GMT -8. The time now is 02:17 PM.

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