Checking for process running on Mac OS X

I'm working with a teensy in the Arduino IDE as a USB keyboard and can get it to open browser (Chrome or Firefox) and go to a random specified web page upon a button push (or other digital input). Think of it like a physical version of StumbleUpon. Now I am wondering if it is possible to to add an if/else conditional to the code to check first to see if the browser is already open so it doesn't go through the process of reopening the browser. Is it possible to determine if a process (the browser) is already running in OS X? How would I do this? Similarly, if it is open is there a way to call the program to the forefront?

Currently I have something that takes advantage of Spotlight that is a complete kludge, but works! I know there's got to be a more elegant solution. It just sends keyboard commands (apple-space, "Firefox", enter...).

Here's the void loop:

void loop(){
if(digitalRead(0)==LOW)
{
Keyboard.set_modifier(MODIFIERKEY_GUI);
Keyboard.send_now();
Keyboard.set_key1(KEY_SPACE);
Keyboard.send_now();
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(500);
Keyboard.print("Firefox");
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.set_key1(0);
delay(1000);
Keyboard.set_modifier(MODIFIERKEY_GUI);
Keyboard.send_now();
Keyboard.set_key1(KEY_L);
Keyboard.send_now();
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
Keyboard.print(names[random(0,NUMBER_OF_PAGES)]);
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.set_key1(0);
delay(1000);
}
}

Thanks!

Doing anything as a USB Keyboard is going to end up being a kludge. The method you are using now won't launch multiple copies of the web browser anyway (since OSX doesn't launch an application twice.)

It might be less kludgy to install a Launcher (like Alfred or LaunchBar) on the host machine. Then you could just open it when the keyboard shortcut (cmd-space) and "type" the URL you want loaded.

This is true, but as it stands it will work on any Mac no installation needed. Walk up, pug in, and surf away.

his is true, but as it stands it will work on any Mac no installation needed. Walk up, pug in, and surf away.

Except that no installation of OS X comes with either Firefox or Chrome. So some kind of installation is necessary already.

Point well taken.