auto clicker help

i am attempting to make an auto clicker in applescript by using mousekeys that allow you to use “i” as a left click with your mouse. The problem im having is that the keystroke command types i instead of using it as a click. this is what i have so far.


set x to 10
repeat x times
     delay (3)
     tell application "System Events" to keystroke "i"
end repeat
 

Am i going about this the wrong way or am i using the wrong command. please help.

The Process suite of the System Events dictionary understands “click”. You can just tell System Events to click.

repeat 10 times
	delay 3
	tell application "System Events" to click menu item "Name" of ((process "Finder")'s (menu bar 1)'s ¬
		(menu bar item "View")'s (menu "View")'s ¬
		(menu item "Arrange By")'s (menu "Arrange By"))
	beep
end repeat