Apple Scripting Help

K

kratzy

Guest
Hello all! I posted the other day in the Anything Goes forum about looking for some kind of macro/bot that would produce a mouse click every 2 minutes or so. Someone suggested putting the following into Apple script:

tell app "system events"
repeat
delay 60
click
end repeat
end tell

I'm not sure this is correct but I'm fairly certain that with some tweaking this is on the right track. Anyone know a bit about apple script? thanks in advance

Kratzy
 
OP
K

Kokopelli

Guest
Well it was close. There are two problems. The first is that a repeat needs a type and a conditional. That is easily solved.

Code:
tell application "System Events"
	
	repeat while true
		delay 60
		click
	end repeat
	
end tell

The second is that click simulates a click upon some UI element. Since no UI element is specified I am not sure if the OS will actually register the mouse as clicked.

P.S. If you want to confirm the loop just add a sialog inside the loop. that is what I did.

Code:
	display dialog "Loop Ran" buttons {"OK"} default button 1

p.p.s might want to run it from script editor or change it to a for loop. Not sure how you would kill an applescript running in an infinite loop.
 
Joined
May 26, 2005
Messages
243
Reaction score
16
Points
18
Location
Walsall, England
Kokopelli said:
p.p.s might want to run it from script editor or change it to a for loop. Not sure how you would kill an applescript running in an infinite loop.

Won't an applescript show up on the dock like an application would while it's running? You should be able to quit or force quit that way if there is ever a problem...right?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top