Jump to content
7 posts in this topic

Recommended Posts

I wrote a little script to detect displays for me that I just put in my login items so it does it automaticly on login. Hope it helps someone. Here is the script.

 

tell application "System Preferences" to activate
delay 2
tell application "System Events"
tell process "System Preferences"
	click menu item "Displays" of menu "View" of menu bar 1
	delay 3
	tell button "Detect Displays" of group 1 of tab group 1 of window "Display" to click
end tell
end tell

Edited by vizual.menace
Link to comment
https://www.insanelymac.com/forum/topic/45697-applescript-for-detect-displays/
Share on other sites

  • 2 years later...
  • 11 months later...

Hi

 

The script does not work for me in OSX 10.6.3

 

I got the error:

 

System Events got an error. Can't get button "Detect Displays" of group 1 of tab group1 of window "Display" of process "System Preferences".

 

Any idea what needs to be changed?

 

Many thanks in advance.

Have you tried adding a keyboard shortcut to do this

 

go to system preferences/keyboard/keyboard shortcuts

 

hit the plus sign

 

type in Detect Displays

 

Then add a shortcut

 

 

logout or restart and give it a try, i cant verify that this works!

 

let me know if not and i can write a new script

  • 4 months later...
The script does not work for me in OSX 10.6.3

 

didn't work for me in 10.6.4

 

I adjusted it, basically adjust the target for the click:

 

		tell button "Detect Displays" of window 1 to click

 

here's the whole thing. this one also quits system prefs at the end, and I took out the delays. I didn't seem to need them.

 

tell application "System Preferences" to activate
tell application "System Events"
tell process "System Preferences"
	click menu item "Displays" of menu "View" of menu bar 1
	tell button "Detect Displays" of window 1 to click
end tell
end tell
tell application "System Preferences" to quit

 

 

P.S. thanks to the OP for rapidly leading me to a solution.

×
×
  • Create New...