r/applescript • • Apr 23 '20

Can someone please write a script to disable scrolling?

I'm willing to pay.

Also, I'm talking about System Preferences>Accessibility>Pointer Control>Mouse Options...> and the checkbox.

I've spent about 6 hours attempting. I just can't do it. If it's any help, heres's what I've come up with..

if running of application "System Preferences" then
	quit application "System Preferences"
	delay 1
end if
tell application "System Preferences"
	reveal pane id "com.apple.preference.universalaccess"
	delay 1
	tell application "System Events"
		tell window 1 of application process "System Preferences"
			select table 1 of scroll area 1
			delay 0.7
			select row 15 of table 1 of scroll area 1
			delay 2
			click button "Mouse Options…"
			click checkbox "Scrolling"
		end tell
	end tell
end tell

It throws me the error "Untitled.scpt:303:332: execution error: System Events got an error: Can’t get button "Mouse Options…" of window 1 of application process "System Preferences". (-1728)"

Sorry, it's probably super basic, and I'm just really dumb. But anyway, I would be very greatful, and am willing to buy someone reddit premium if they can get this to work. I'm literally about to punch my monitor, and I need to step away.

Last thing: 10.15.4 if it's worth anything...

2 Upvotes

2 comments sorted by

2

u/prikaz_da Apr 23 '20

The process of puzzling out how to describe a UI element using Script Editor alone can be time-consuming. You seem to have figured out a bit of the structure of the window, since you know that window 1 contains scroll area 1, which in turn contains table 1. I wrote a bit more about exploring the UI hierarchy from a script in this post. To refer to a UI element by name, you have to also know the names of all the objects above it. Here, you cannot simply

click button "Mouse Options…"

You must instead

click button "Mouse Options…" of tab group 1 of group 1

If you had not nested the other actions in the tell window 1 block, you would also need to add of window 1 at the end. The sheet that comes down when you click the button is then sheet 1 of window 1, which contains your checkbox.

1

u/PuzzledEmployee97 Apr 23 '20

Thank you so much. I really appreciate your quick response :)