Defer by hour keyboard shortcut

Hi, i’m trying to use an applescript along with Keyboards Maestro to set keyboard shortcuts to defer date by hours. I have used this script to defer by days/weeks/months and it works great: https://c-command.com/scripts/omnifocus/defer-to-tomorrow

But i’d like to be able to defer something 3 hours, or 6 hours. I tried playing around with the script but am not very knowledgeable with applescript. Can you please help me figure out how to make this work?

Thanks, Dan

Maybe this would help.
Code:

--GET CURRENT DATE
set the_date to (current date)

tell application "OmniFocus"
	set oWin to front document window of front document
	tell content of oWin
		--GET SELECTED ITEMS IN THE CONTENT OF FRONT DOCUMENT WINDOW
		set lst_trees to selected trees
		
		--REPEAT WITH EVERY SELECTED ITEM
		repeat with i in lst_trees
			set the_task to value of i
			set task_name to name of the_task
			set the_answer to text returned of ¬
				(display dialog task_name with title "¿How many hours would you like to defer this task?" default answer "1")
			set the_answer to the_answer as integer
			
			--USE CONSTANT "HOURS" TO ADD NUMBER OF HOURS TO CURRENT DATE
			set defer_date to the_date + (the_answer * hours)
			set defer date of the_task to defer_date
		end repeat
	end tell
end tell
1 Like

perfect ! thanks!!

You’re welcome!