How can I open an app with the push of a button?

I want to be able to open an application with a button. I am trying to do it when I push F1 (or any other unique button). I am not very familiar with this sort of command. Can anyone help. Here is what I though would work:

tell application "System Events"
	if keystroke "F1" then
		activate application "iChat"
	end if
end tell

Requiers Jon’s Commands But:

repeat until (keys pressed) contains "F1"
	tell app "iChat" to activate
end repeat

i get an error with this script. Also, if it were to work, it would make the application repeatedly open untl F1 is pushed. Is this right?

here is the error I get:

Expected ", " but found identifier.

the word “pressed” is highlighted

what would cause this?

In this case it’s better to use a third party app like xkeys, unless you have Apple’s built in.

I think it’s still freeware.

ps. I think you don’t have Jon’s Commands scripting addition installed. That’s why ‘keys pressed’ doesn’t work.


Has anyone here ever used his scripts stuff? I downloaded it, but I cant figure out where to put it or what to do woth it. Not much explaination.

Ok, i sort of have a clue here. Do I need version 2.1.2 or 3.0d3? Also, it says I am suppost to put it in “the same file as the script editor”. What is this? Thanks!

The 3.0d3 is the osx version of jon’s commands. You place it in the scripting additions folder in your system library folder if you want all users to have access to it. Otherwise, you place it in your home folder. If you don’t have a scripting additions folder yet in your home library folder run this in the script editor:

path to scripting additions folder from user domain

or you can just make your own scripting additions folder. Here’s the path to mine:

“Macintosh HD:Users:kel:Library:ScriptingAdditions:”

You place Jon’s Commands scripting addtion in this folder. I don’t know why you don’t want to use xkeys, but since you’re trying Jon’s Commands, you should use an idle handler or a repeat loop with a break at least. Something like this:

on idle
if (keys pressed) contains “F7” then
display dialog “hi”
end if
return 1
end idle

You save this type of script as stay open application which you set in the Script Editor save dialog.


Thanks! That is great! Here is what works. I am going to save it as an app. Is there anything you think is odd or unstable about it? Thanks! Ian

	if (keys pressed) contains "F7" then
		tell application "System Events"
			tell process "SecuritySpy"
				click menu item "Main preview window" of menu "Window" of menu bar item "Window" of menu bar 1
			end tell
		end tell
	end if
	delay 0.5
end repeat

Hi. I’m new to applescript…in fact I’m new to apple period! (Shame) But I’ve done basic programming before.

I would also like to control SecuritySpy a bit more with applescript.

In addition to opening the program via keyboard, I’d like to be able to “set all cameras to active mode after a delay” of say 400sec. in other words make the cameras start recording but only after a delay (ie when I’ve left the house.) This fuction sits under the “control” tab of the main menu bar of the program and can be activated by pushing that skwiggly mac button together with the the D button!

Appologies for my ignorance! BTE I now own 3 MACS having used PC’s all my life and I’ll never return to the dark side! They run my multiroom audio, my backup and now my security system flawlessly! Awesome.