Jump to content
  • Announcements

    • Allan

      Forum Rules   04/13/2018

      Hello folks! As some things are being fixed, we'll keep you updated. Per hour the Forum Rules don't have a dedicated "Tab", so here is the place that we have our Rules back. New Users Lounge > [READ] - InsanelyMac Forum Rules - The InsanelyMac Staff Team. 
vizual.menace

Applescript for Detect Displays

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

Share this post


Link to post
Share on other sites
Hi

 

 

 

Why does this script not work in osx 10.5.6 ?

 

Whats Changed ?

 

Many thanks in advance

 

P

It works fine in 10.5.6.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

×