opening location from bookmark bar in safari

i want to open a location which is in my bookmarks bar, which i can open manually by pressing ‘command + 1’. i can’t seem to get this done using an applescript though. here is the bit of my script which doesn’t work.

tell application "System Events"
	tell process "Safari"
		set frontmost to true
		keystroke "1" using command down
	end tell
end tell

unless i’m mistaking the clover leaf button for something other than ‘command’, i don’t see the problem in the script. how do i fix this? thanks for any help.:smiley:

Model: iBook G4
AppleScript: v2.1 (80)
Browser: Safari v2.0 (412)
Operating System: Mac OS X (10.4)

Snake, I’m not sure why you’re script doesn’t work. However, you can try this:

tell application "System Events"
	tell process "Safari" to set frontmost to true
	key code 18 using command down
end tell

You can determine key codes with Full Key Codes.

thanks that’s a good solution. still it’s weird though. this works:

keystroke "1"

but this doesn’t:

keystroke "1" using command down