What User of several is active?

I saw a question on another forum that boiled down to this: if Fast User Switching is running with two accounts logged in, how can I detect which one is “active”? What was wanted was to run a script when one of the users became active on a shared machine, but the key is to detect the switch from one of the accounts, isn’t it?

While I’d still love to know whether this was possible in AppleScript, a donationware application called “WinSwitch”, a better FUS facility, essentially solves the problem.

Does this help? :rolleyes:

on currentUser() -- careful: this gets the user running this script
	tell application "System Events"
		name of current user
	end tell
end currentUser


Model: Alu-PowerBook 15" 1.25 GHz
AppleScript: 1.10
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

It does return the name of the current user, of course, but it isn’t a trigger unless it’s left running as an on idle script.