postprefix
5/31/2013 - 1:30 AM

Alfred.app Append to nvALT Daily notes.applescript

on alfred_script(q)
	set theYear to year of (current date) as string
	
	set theMonth to (month of (current date) as number)
	
	if theMonth < 10 then
		set theMonth to "0" & theMonth
	else
		set theMonth to "" & theMonth
	end if
	
	set thisDate to (day of (current date) as number)
	
	if thisDate < 10 then
		set thisDate to "0" & thisDate
	else
		set thisDate to "" & thisDate
	end if
	
	set theDate to "" & year of (current date) & "-" & theMonth & "-" & thisDate
	
	set theHours to (hours of (current date) as number)
	
	if theHours < 10 then
		set theHours to "0" & theHours
	else
		set theHours to "" & theHours
	end if
	
	set theMinutes to (minutes of (current date) as number)
	
	if theMinutes < 10 then
		set theMinutes to "0" & theMinutes
	else
		set theMinutes to "" & theMinutes
	end if
	
	set theTime to theHours & ":" & theMinutes
	
	tell application "nvALT"
		activate
		tell application "System Events"
			keystroke "l" using {command down}
			keystroke "Daily notes" & return & return
			keystroke (ASCII character 30) using {command down} -- command + up arrow to go to top of note
			keystroke theDate & " " & theTime & " -- " & q
			-- keystroke "v" using {command down} -- Command+v
			keystroke return
			-- Change this part to your global hotkey
			keystroke "n" using {command down, control down, option down}
		end tell
	end tell
end alfred_script