Crash Report Zipper

I was working with an alpha copy of a new app that crashed fairly frequently so wrote this to grab the latest crash report and zip it. I’ve left out the part for attaching and mailing it because that is specific to your mailer.

[Edit: moved activate command. Important!}

set crashLogs to ((path to library folder from user domain as text) & "logs:CrashReporter:")
set appName to text returned of (display dialog "Please enter the name of the application without an extension" default answer "theApp" buttons {"Cancel", "Zip It"} default button 2 with title "Crash Grabber")
tell application "Console"
	open alias (crashLogs & appName & ".crash.log")
	activate
	tell application "System Events" to tell process "Console"
		keystroke "a" using {command down}
		delay 1
		keystroke "c" using {command down}
		delay 1
		set tCrash to the clipboard
		set tid to AppleScript's text item delimiters
		set AppleScript's text item delimiters to "********"
		set JCD to last text item of tCrash
		set AppleScript's text item delimiters to tid
	end tell
	quit
end tell
set D to short date string of (current date)
set fileName to appName & " Crash " & D
set CrashFile to ((path to desktop folder as text) & fileName)
set CF to open for access CrashFile with write permission
try
	set eof of CF to 0
	write JCD to CF
	close access CF
on error
	close access CF
end try
set toZip to quoted form of POSIX path of CrashFile
set Zipped to quoted form of POSIX path of (CrashFile & ".zip")
do shell script " /usr/bin/ditto -rsrc -c -k " & toZip & space & Zipped