Newbie cant get 304 to work

the interface says accessibility NOT allowed, but its checked ON in the System prefs.

after I get it to work, I’d like to know how to make “click at” work

I had exactly that problem. Try restarting the machine. For me, it worked after doing that.

thanks, that did not work for me.

Try it again. It may have taken me two or three tries for it to “stick.”

Can someone please explain what “304” is?

This code produces mouse clicks here.

--Running under AppleScript 2.8, MacOS 15.7.5
on UI_Mouse_Click_Left_At_Point(aPoint)
    set updateMouseCursorPosition to true
    set buttonIndex to 1
    set mouseButtonDown to true
    current application's CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonIndex, mouseButtonDown)
    delay 0.1
    current application's CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonIndex, not mouseButtonDown)
end UI_Mouse_Click_Left_At_Point

Took me a while to figure out that “304” refers to UI Browser 3.0.4.

1 Like

so this code is a handler, it uses “ON”. can you make this a script without the ON, or, give me all the code I need to make the ON handler work, thank you.

Not sure if that’s directed at me or not. If it is, here’s code that determines the current mouse location and passes that value to a revised UI_Mouse_Click_Left_At_Point() handler as my previous version used now-deprecated methods.

If you want to target a specific location you can determine the values using UI_Mouse_Position_Get() and separately pass hard-coded vales to UI_Mouse_Click_Left_At_Point(aPoint)

use AppleScript version "2.4"
use framework "Foundation"

set aPoint to UI_Mouse_Position_Get()
UI_Mouse_Click_Left_At_Point(aPoint)

on UI_Mouse_Position_Get()
	--Getting the screen resolution and the bottom bound.
	tell application "Finder" to set screen_resolution to bounds of window of desktop
	set theBottom to item 4 of screen_resolution
	--Getting current mouse position. {0,0} is top left corner of screen.
	set currentMousePosition to (current application's NSEvent's (mouseLocation)) as record
	set x to (currentMousePosition's x) as integer
	set y to theBottom - (currentMousePosition's y) as integer
	return {x, y}
end UI_Mouse_Position_Get

on UI_Mouse_Click_Left_At_Point(aPoint)
	tell application "System Events"
		click at aPoint
	end tell
end UI_Mouse_Click_Left_At_Point