PDA

View Full Version : Please help finish a script to launch Minuteur with a task's estimated time


smew
09-03-2007, 08:17 PM
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
09-05-2007, 07:32 AM
It looks like the previous post lost the script attached. Trying again: both attached and here (http://www.mediafire.com/?9uxb4o91or9).

RobTrew
09-05-2007, 10:30 AM
That's an interesting idea.

You could experiment with something like this, for example:

-- 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"

RobTrew
09-07-2007, 04:29 PM
A simplified script with minimal messages might look like:

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

smew
09-11-2007, 04: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
09-11-2007, 10:04 PM
I can't get the script to do anything more than just activate Minuteur...

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
09-15-2007, 04: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
09-15-2007, 05: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
09-15-2007, 09:14 PM
Minuteur 5

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

RobTrew
09-15-2007, 10: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 Minuteur 4 (http://www.phg-home.com/index_mac.html), which seemed to have some kind of applescript problem, so I do recommend that you write to the author (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%2 0%64%65%20%74%6F%6E%20%73%69%74%65%2E%2E%2E) and ask for version 5. (No need to write in French, if that is deterring you :-)

RobTrew
09-15-2007, 11:02 PM
Qu'est-ce que c'est?

Eh bien ... c'est un minuteur (http://www.phg-home.com/index_mac.html) !

It is a very easily used count-down timer (or stop-watch) with an alarm. The script allows you to start running it automatically for the amount of time specified in the Duration field of an action.

It was recommended in Merlin Mann's blog (http://www.43folders.com/2005/11/15/mac-timers/) some time ago.

smew
09-16-2007, 09:41 AM
OK, email sent to the author. Holding breath :D

smew
09-16-2007, 12:50 PM
OK, I got Minuteur 5 and everything is working properly. Yay! NOW I can try to actually get things done :D

granin
09-20-2007, 01:48 PM
OK, I got Minuteur 5 and everything is working properly. Yay! NOW I can try to actually get things done :D

I've also got version 5 but script doesn't work, nither original nor simplified one, could you please post final version that works for you ?

RobTrew
09-20-2007, 02:25 PM
Should work as posted.

Copy the attached to ~/Library/Scripts/Applications/Omnifocus

then, right-click on the Omnifocus toolbar, choose Customize Toolbar, and drag the icon of the script onto the Toolbar.

Clicking the icon while a task is selected will launch Minuteur, as long as the Duration field is not empty.

(Make sure, of course, that Minuteur 5 is in your applications folder, and that Minuteur 4 has been removed)

Craig
09-21-2007, 06:54 AM
Works for me - pretty cool!

Any way it could be modified to add together the durations when multiple items are selected?

RobTrew
09-21-2007, 07:38 AM
Any way it could be modified to add together the durations when multiple items are selected?

Good idea.

Amended accordingly - try this.

Craig
09-21-2007, 02:11 PM
Seems to work. Thanks for this. If I can get in the habit of assigning durations, I can see this being very useful.

Somebee
10-06-2007, 01:48 AM
This is a very good idea! A very nice addition (for myself atleast) would be a script that stops the minuteur-clock, and appends to the task-name in OF like "... (took 8m)". It could also mark of the task as checked.

This would be very cool. The way I get things done nowadays is to race myself and try to beat my time-estimate on the tasks, and a script that appends the actual time it took would be very helpful! The prerequisite to this is that applescript has to remember which task you started the minuteur-clock with.