View Single Post
wild4life

 
Member Since: Aug 03, 2013
Posts: 3
wild4life is on a distinguished road

wild4life is offline
as I said in the post above I am trying to create an applescript that will automatically change to the priority of the todo list item based on the due date.

I have found an application called Things that is scriptable.

I also have the script addition Satimage.osax which has some useful commands.

I have started the applescript using Things at the moment I have it sorting the to do by priority.
I would like it to sorted them by date and if there are two with the same date then to look in the notes of the to do where I put the time and sort them by time.

The code below is what I have so far which sorts them by priority.

Main
Code:
tell application "Things"
	try
		close window "Things"
	end try
	set thelist to {}
	set theToDos to to do of list "today"
	set theCount to count theToDos
	repeat with i from 1 to theCount
		set ToDo to to do i of list "today"
		
		set thename to name of ToDo
		set theduedate to due date of ToDo
		set theduedate to date string of theduedate
		set thenote to notes of ToDo
		set thepriority to tag names of ToDo
		
		set theToDo to " " & thename & return & "due: " & theduedate & return & thenote & return & "priority: " & thepriority & return
		
		set end of thelist to theToDo
		
	end repeat
	set listCount to count thelist
	set new_list to {}
	repeat with f from 1 to listCount
		set itemlist to get item f of thelist
		set lastword to last word of itemlist
		
		if lastword is equal to "High" then
			set beginning of new_list to itemlist
			
		else if lastword is equal to "Medium" then
			set end of new_list to itemlist
			
		else if lastword is equal to "Low" then
			set end of new_list to itemlist
			
			
		end if
		
		
		
	end repeat
	
	
	
	
	
	
	
	tell application "Finder"
		activate
		display dialog new_list as string buttons {"OK"} default button 1
	end tell
end tell
the code below can be used to extract to time from the notes as I put other information in the notes as well as the time in this format 14:00.
Code:
set theOffset to offset of ":" in thenote
set num to theOffset - 2
set thetime to text (theOffset + 2) thru num of thenote
set thehours to characters 1 thru 2 of thetime as string
set themins to characters 4 thru 5 of thetime as string
here is the command to set the priority in things below
Code:
set tag names of ToDo to "High" --"Medium" or "Low"
the ToDo is a variable I set in the main code above.

thanks for any help
QUOTE Thanks