Exposé and the System Preferences (and the click command)

Hi, I was trying to change some preferences in the Exposé panel of the System Preferences via AS, but it’s gotten complicated. What I want to do is change a “Hot Corner”, then execute an app, and then restore it after I quit the app. The disctionary talks about panes, but I don’t know how to handle them…
I tried a few things like:


tell application "System Preferences"
	try
		
		set Paneles to get name of every pane
		--set Paneles to get localized name of every pane
		if "Exposé" is in Paneles then
			tell preferences window to open (pane whose localized name is "Exposé")
		else if "com.apple.preference.expose" is in Paneles then
			tell preferences window to open (pane whose name is "com.apple.preference.expose")
		end if
		current pane
		
	on error ElError
		activate
		display dialog ElError
	end try
	activate me
end tell

(*
tell application "System Events"
	tell process "System Preferences"
		keystroke "l" using command down -- doesn't work...
	end tell
end tell
*)

but since the use of panes is a mistery to me… do you open panes, tell them things…:?:

Then I tried “clicking” the buttons:


-- choose file without invisibles
set BaseX to 30
set BaseY to 50

tell application "Finder" to open alias (((path to "dlib" from system domain) as text) & "PreferencePanes:Expose.prefPane:")

tell application "System Preferences"
	set {TopX, TopY, BottomX, BottomY} to get bounds of window 1
	set bounds of window 1 to {BaseX, BaseY, BottomX - TopX + BaseX, BottomY - TopY + BaseY}
end tell -- Just to relocate, nothing relevant.

delay 1

tell application "System Events"
	tell process "System Preferences"
		-- tell application "System Preferences" to activate
		-- if "Hot Corner" is set to "Start Screen Saver" then
		click at {495 - BaseX, 235 - BaseY} -- {X,Y} according to {0,0} of the window
		click at {495 - BaseX, 285 - BaseY} -- This one shouldn't work, read foot note.
		delay 1 -- set it to "Do Nothing"
		click at {495, 235} -- {X,Y} according to {0,0} of the Mac screen 
		click at {495, 285} -- This one should work.
		-- else if "Hot Corner " is set to "Do Nothing" then
		click at {495 - BaseX, 235 - BaseY}
		click at {495 - BaseX, 185 - BaseY}
		delay 1 -- set it to "Start Screen Saver"
		click at {495, 235}
		click at {495, 185}
		-- end commented if
	end tell
end tell

activate me

(*
System Events dictionary, Processes Suite:

click: cause the target process to behave as if the UI element were clicked
	click  UI element  -- The UI element to be clicked.
		[at  list]  -- when sent to a "process" object, the { x, y } location at which to click, in global coordinates
	Result:   UI element  -- the reply for the command
*)

but it doesn’t click, darn!! So I’m running out of options lol :slight_smile: :?: !!

Anyone have any ideas? I’d appreciate them! Thanks a lot! And Merry Chistmas!

property theExposeDefinition : {topLeftCorner:"wvous-tl-corner", topRightCorner:"wvous-tr-corner", bottomLeftCorner:"wvous-bl-corner", bottomRightCorner:"wvous-br-corner", doNothing:1, allWindows:2, appWindows:3, showDesktop:4, startScreenSaver:5, disableScreenSaver:6}

set theCorner to theExposeDefinition's bottomLeftCorner
set theAction to theExposeDefinition's showDesktop

set theScript to "defaults write com.apple.dock " & theCorner & " -int " & theAction & " ; killall Dock"

do shell script theScript