Accessing Fast User Switching through a script

I want to be able to create a script that can select then next account in my Fast User Switching menu in Panther. I would then set a key stroke to activate it so I can have something similar to virtual desktops.

I downloaded the UI plugin and am trying to figure out how to control that menu. I can activate it, but have no clue how to switch users. Could anyone help me in this area?

I new to AppleScript so I apologize for my apparent ignorance. I downloaded a pdf called AppleScript for Absolute Starters that got me interested. Unfortunately it isn’t updated for Panther and so not everything it says is accurate.

Thanks for the help.

Consult:
http://www.macosxhints.com/article.php?story=20031102031045417

or try:


set SysZooi to {"nobody", "daemon", "unknown", "smmsp", "lp", "postfix", "www", "eppc", ¬
	"mysql", "sshd", "qtss", "cyrus", "mailman", "appserver", ""} --"root"

set userArray to {"Login Screen"}
set uidArray to {"-10"}

set theUsers to do shell script "niutil -list . /users | awk '{printf "%s///", $2}'"

set AppleScript's text item delimiters to "///"
set thePropertiesList to text items in theUsers
set AppleScript's text item delimiters to ""
set theCurrentUser to do shell script "echo $UID"
repeat with theProperty in thePropertiesList
	if the length of theProperty > 0 and theProperty is not in SysZooi then -- to skip the last item.
		set myScript to "niutil -readprop . /users/" & theProperty & " shell"
		if (do shell script myScript) is not equal to "/dev/null" then -- a real user
			set myLongName to do shell script "niutil -readprop . /users/" & theProperty & " realname"
			set myUID to do shell script "niutil -readprop . /users/" & theProperty & " uid"
			if (myUID as number) is not equal to (theCurrentUser as number) and (myUID as number) is not equal to 0 then
				-- Skip self and the root user (alter to your liking, though switching to self might have side effect
				set userArray to userArray & {myLongName}
				set uidArray to uidArray & {myUID}
			end if
		end if
	end if
end repeat

--tell application "System Events" to ¬
--	set fApp to (some process whose frontmost is true)'s name
set fApp to "Finder"
beep
tell application fApp to activate
-- present the dialog box.
tell application fApp to ¬
	set theSwitch to choose from list userArray with prompt "Switch to:" OK button name "Switch" without multiple selections allowed and empty selection allowed

-- figure out the uid of the new user (or if the login window was choosen).
if theSwitch is not false then
	set theNewUser to item 1 of theSwitch
	set theIndex to 0
	set theNewUID to -1
	repeat with myUser in userArray
		set theIndex to theIndex + 1
		if (myUser as string) is equal to (theNewUser as string) then
			set theNewUID to item theIndex of uidArray
		end if
	end repeat
	if (theNewUID as number) < 0 then -- the code from MacOSXHints.com
		do shell script "/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
	else
		do shell script "/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID " & theNewUID
	end if
end if