Rotate Monitor 90º

New to Better Touch Tool. Sorry if this is a dumb question. Is there a way to set a command to automatically rotate my monitor? I have monitor on an arm and at least once a day I switch the orientation of the monitor (portrait vs landscape). I then have to go into system preferences and change it. Hoping for a faster way.

An UI apple script could do this quite easily.

Thanks. I don't know how to do that. Can you point me to some resources to help me learn how?

If it's fine for you to wait 10d I can do it afterwards.
Here is some UI scripting from the settings app from my preset:

try
	tell application "System Preferences"
		set current pane to pane "com.apple.preference.trackpad"
	end tell
	
	tell application "System Events"
		tell process "System Preferences"
			click radio button "Scroll & Zoom" of tab group 1 of window "Trackpad"
			click checkbox 2 of tab group 1 of window "Trackpad"
			click checkbox 3 of tab group 1 of window "Trackpad"
			click checkbox 2 of tab group 1 of window "Trackpad"
			click checkbox 3 of tab group 1 of window "Trackpad"
		end tell
	end tell
	tell application "System Preferences"
		quit
	end tell
end try

The pane should be com.apple.preference.screens, but as you have to open it up with the ⌘⌥ keys clicked it could be easier to do something

tell process "System Preferences"
tell window thisDisplay
tell tab group 1
click radio button "Display" 

No clue :man_shrugging:t2: Try to find sth by your self, you'll also have to discover the name of the menu to be enrolled, I'll look into this after my exams :ok_hand:t3:

Even easier would be a simple command line, but I didn't find a native way to do this on macOS, only third party tools.

@Caliguvara Did you finish those exams? I'd love to create a shortcut for that, but I know nothing of apple scripts...will try looking it up by myself, but if you ever get some spare time a little help would be much appreciated :slight_smile:

Wow, this is an old one :smiley:

Try this website I found on Google. The guy presents some terminal code, should work way better than Apple Script.

I do not have any external screen in my current place, I'm not able to check this out though :man_shrugging:t4:

I'm bumping this because I am wondering if anyone has found a better solution.

Is there a way to quickly change the display rotation that doesn't involve UI window scripting or giving additional terminal/accessibilty permissions?

In the past, I have used applescript to do it in the UI, but it was always a headache to get the delays correct for the Systems Preference window opening and closing.

I think the displayplacer command line utility can do this: GitHub - jakehilborn/displayplacer: macOS command line utility to configure multi-display resolutions and arrangements. Essentially XRandR for macOS.

//edit: looks like it doesn’t work well on apple silicon though

Thanks for the suggestion, but I am on an M1. :frowning:

I'll try to resurrect my old UI applescripts, but I remember they were a bit slow and not always reliable in practice.

Edit: Giving up.
Apple has changed something about the windows architecture for UI elements, post Monterey. Applescript can't grab some UI elements, even when it's the right path, indexed or not. I could try a "Watch Me Do" process but that is always so brittle that it probably won't save any real time or frustration in the end. It's just Apple phasing out their own useful, already-achieved functionality again.

I hope adding this helps someone somewhere. This worked, for a Mac Mini M1 on Monterey. If you ask me how it worked, I will tell you, "I don't know." I won't be surprised if it falls apart on the next update.

tell application "System Preferences"
	activate
	reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
	delay 1
	(*set current pane to pane id "com.apple.preference.displays"*)
	delay 1
	
	tell application "System Events"
		tell its application process "System Preferences"
			tell pop up button 2 of group 1 of window 1
				delay 1
				if (value) contains "90°" then
					delay 1
					click
					click menu item "Standard" of menu 1
					delay 1
					
				else
					delay 1
					click
					click menu item "90°" of menu 1
					delay 1
					tell application "System Events"
						tell its application process "System Preferences"
							tell button 2 of sheet 1 of window 1
								delay 1
								click
								delay 2
							end tell
						end tell
					end tell
				end if
				
			end tell
		end tell
	end tell
	quit application "System Preferences"
end tell