Using keystroke commands

I am trying to use keystroke command to mark a mail message as flagged. The script I have writtem compiles and runs but does not do anything can anyone hlep please.

tell application "Mail"
	set themsg to selection
	set themsg to item 1 of themsg
	tell application "System Events"
		tell process "mail"
			keystroke "L" using {command down, shift down}
		end tell
	end tell
end tell

Same problem here – this script compiles and runs without error, but doesn’t flag the selected mail:


(*tell application "Mail"
	set themsg to selection
	set themsg to item 1 of themsg
end tell*)
tell application "System Events" to tell application process "Mail"
	activate
	try
		perform action "AXPress" of menu item "As Flagged" of menu 1 of menu item "Mark" of menu 1 of menu bar item 7 of menu bar of window 1
	on error E
		display dialog E
	end try
end tell

Hi

This now works for me I had overlooked activating mail so I kept opening the library in Applescript.

tell application "Mail"
	activate
	tell application "System Events"
		tell process "mail"
			keystroke "l" using {command down, shift down}
		end tell
	end tell
end tell

Should not have taken me so long to figure it out guess I had too much stuff open on my desktop