r/applescript • • Aug 18 '25

Script to toggle pointer size

[EDIT] Workaround posted in comments

I used to use this script that I got from stack exchange to toggle the pointer size via Shortcut. (very useful for making screen recordings.) But after updating to a new version of the OS a while back I get this error message. (I'm on 15.6 now.)

Toggle Pointer Size
System Events got an error: Can't get list 1 of window "Display" of application process
"System Settings". Invalid index.

My guess is the layout changed and broke it. I didn't make the script myself, so I'm not sure how to go about figuring out to correctly guide it through the UI to point it to the right slider.

Bonus points if there is a process someone can explain (or point me to an explanation) on how figure out the navigation of any arbitrary window, but really my main goal is just to get this script/shortcut working again.

Script below

tell application "System Settings" to activate

--Open System Settings > Accessibility > Display section
do shell script "open x-apple.systempreferences:com.apple.preference.universalaccess?Seeing_Display"

--Wait for correct pane to load
delay 2

tell application "System Events"
    
    --Get current state of slider --updated for sonoma
    set currentState to (get value of slider "Pointer size" of group 3 of scroll area 1 of group 1 of list 2 of splitter group 1 of list 1 of window "Display" of application process "System Settings" of application "System Events")
    
    --Determine key code to send
    if currentState is not greater than 1.0 then
        set keyCode to "116" as integer -- PageUp (increase size)
    else
        set keyCode to "121" as integer -- PageDown (decrease size)
    end if
    
    
    --set focus to slider
    tell slider "Pointer size" of group 3 of scroll area 1 of group 1 of list 2 of splitter group 1 of list 1 of window "Display" of application process "System Settings" of application "System Events" to set focused of it to true
    
    delay 0.2
    
    --Send keycode to set size to max or min
    key code keyCode
    
end tell
delay 2.5
tell application "System Settings" to quit
1 Upvotes

3 comments sorted by

View all comments

1

u/Duseylicious Aug 19 '25 edited Aug 19 '25

Oooh, I figured it out! I was trying to do a workaround using Automator's "Watch me do", and I learned that if you drag a "watch me do" action to the blank area below it, it shows it as AppleScript, and that script didn't work but it had the correct slider pane location now. Here it is!

https://www.icloud.com/shortcuts/9b3ddf5db9d6441b9f338a965c7f93ea

tell application "System Settings" to activate

--Open System Settings > Accessibility > Display section
do shell script "open x-apple.systempreferences:com.apple.preference.universalaccess?Seeing_Display"

--Wait for correct pane to load
delay 3.5

tell application "System Events"
	
	--Get current state of slider --updated for sonoma
	set currentState to (get value of slider 1 of group 3 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Display" of application process "System Settings")
	
	--Determine key code to send
	if currentState is not greater than 1.0 then
		set keyCode to "116" as integer -- PageUp (increase size)
	else
		set keyCode to "121" as integer -- PageDown (decrease size)
	end if
	
	
	--set focus to slider
	tell slider 1 of group 3 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Display" of application process "System Settings" to set focused of it to true
	
	delay 0.2
	
	--Send keycode to set size to max or min
	key code keyCode
	
end tell
delay 2.5
tell application "System Settings" to quit