Command + Tab like functionality with AppleScript

I am looking to write a AppleScript that will allow me to run the script and have it go through the various open apps like command + tab.

What I am doing, is programming my remote control to control my computer. I have a button setup called “Change App” and when pushed, it will trigger an AppleScript. As for right now, I am just having problems figuring out the AppleScript.

I guess the best functionality would when the script runs, it will bring the backmost application to the front. So ever time I push the button, a new application that is open will come to the front.

Thank You for your help.

This works on Tiger (10.4.11) to mimic the command + tab key command.

It may need some tweaking.

Peter B.



tell application "System Events"
	delay 0.5
	key down command
	keystroke tab
	delay 10
	key up command
	set proc_name to first process whose frontmost is true and visible is true
	set visible of (every process whose frontmost is not true and name is not "Finder") to false
end tell