The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Please help finish a script to launch Minuteur with a task's estimated time Thread Tools Search this Thread Display Modes
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!
 
It looks like the previous post lost the script attached. Trying again: both attached and here.
Attached Files
File Type: zip Launch Minuteur countdown with estimated time.scpt.zip (3.0 KB, 336 views)
 
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"
 
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
 
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...
 
Quote:
Originally Posted by smew View Post
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.
 
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!
 
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.
__________________
Cheers,

Curt
 
Quote:
Originally Posted by RobTrew View Post
Minuteur 5
What's that? Or should I say Qu'est-ce que c'est?
 
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, which seemed to have some kind of applescript problem, so I do recommend that you write to the author and ask for version 5. (No need to write in French, if that is deterring you :-)

Last edited by RobTrew; 2007-09-15 at 10:25 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to finish off a Hazel Rule NewlyHooked OmniFocus Extras 2 2012-10-14 09:48 PM
Estimated Time of Zero skillet OmniFocus 1 for Mac 2 2012-04-09 01:22 PM
Deleting estimated time from script? treyharris OmniFocus Extras 1 2011-10-22 06:35 PM
Estimated Time? sirluce OmniFocus for iPad 3 2010-12-03 03:55 AM
Can OF Give Total Estimated Time? klaing OmniFocus 1 for Mac 2 2009-07-22 07:10 PM


All times are GMT -8. The time now is 12:34 PM.


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