Unable to set slider value in System Settings in macOS 13 or 14

I found this older post, which modifies the cursor size via AppleScript. I managed to update it to work in Ventura and Sonoma, but only in a kludgy manner.

Here's the working code:

set theSystemVersion to system version of (system info)

tell application "System Settings"
	reveal anchor "AX_CURSOR_SIZE" of pane id "com.apple.Accessibility-Settings.extension"
	delay 1.0
	tell application "System Events"
		if (text 1 thru 2 of theSystemVersion) is "13" then
			set contentView to group 2 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"
		else
			set contentView to 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"
		end if
		
		set theSlider to slider 1 of contentView
		set stash to value of theSlider
		
		if value of theSlider is 1.0 then
			--set value of theSlider to 4.0
			repeat while value of theSlider is less than 4
				increment theSlider
			end repeat
			say "Big Mouse" using "Ralph"
		else
			--set value of theSlider to 1.0
			repeat while value of theSlider is greater than 1
				decrement theSlider
			end repeat
			say "Tiny Mouse" using "Ralph"
		end if
		stash
	end tell
end tell

The problem is the two commented out lines: In the original post, those commands work to set the slider to an exact value. In Ventura and Sonoma, they do nothing at all—no errors, just nothing. The script runs fine, but it won't change the cursor size.

The only way I got it to work is via the method you see here—repeatedly incrementing or decrementing the value of theSlider until it was either 4 or 1. (The setting of 'stash' seems completely unnecessary, but I left it there anyway.)

Does anyone know why the command to set a specific slider value is failing? I'd like to be able to set it in one pass, as this method is slow and ugly.

thanks!

Unable to set slider value in System Settings in macOS 13 or 14
 
 
Q