Since templates were discontinued I've been using this AppleScript to make a quick HTML doc:

	#!/usr/bin/osascript
	tell application "System Events"
		keystroke "p"
 using {control down, option down, shift down}
		keystroke "4"
	"<!DOCTYPE html>
	<html lang=\"da\">
	<head>
		<meta charset=\"utf-8\">
		<title>$1</title>
		<meta name=\"description\" content=\"\">
		<style type=\"text/css\" media=\"screen\">
			*{margin:0;padding:0;}
			$2
		</style>
	</head>
	<body>
	$0
	</body>
	</html>"
	end tell

It’s been working fine until now. I’m on beta.11.8, and I’m very sorry, but I don’t know if the problem arose with this update or one of the ones from last week.

The problem is rather unusual. It appears that System Events is reversing the order of the commands.

Instead of simulating the keyboard shortcut for selecting PHP, all of the template is inserted via keyboard simulation, then 4 for PHP is pressed and only THEN the shortcut is pressed. But it doesn’t go back to working, if I reverse the sequence in the command code.

This is what it looks like:

Resultat

Here are the settings for the command:

Settings

Rasmus