1

I want my mouse to rapidly auto-click when I hold the left mouse button and to stop as soon as I release the left button. How can I do this?

I have searched for hours, I didn't find anything! Is there possibly a way to do it with AppleScript? Or if there's a free application that can do this, it's perfectly fine too.

  • 1
    Is there a reason you'd like to use your mouse button instead of a keyboard shortcut? Most of the auto-clickers, of which there are a plethora, can do what you describe in response to a keyboard command but not a mouse click. – tubedogg Feb 17 '15 at 18:54
1

I made a solution for you. Its got a few pieces, it might have taken me forever to come up with, and could probably use some polishing but its pretty darn close to what you wanted. The only thing I cannot see us being able to accomplish is holding the mouse down to do it. I couldn't find anything that would allow us to use the mouseup to turn off our clicking loop, so I used a toggle: Click once to start our crazy clicks , and click again to stop it (I used the middle click button as my start and stop)

We are using applescript, a command line tool for OSX called MouseTools, and an application called MagicPref to assign the script to one of our mouse buttons.

once you download and extract MouseTools, it is just a batch script. I put it and my applescripts inside the same folder (I named the folder superclicks). Now we just need to create a loop that clicks at the current location of the mouse, and a way to break out of that loop.

Here are the two applescript apps we make:

launch.app

global thisFile
set thisFile to (path to me)

global thisFolder
tell application "Finder" to set thisFolder to container of thisFile as text


# Function to check current state / should we should stop clicking
on checkstate()
local clickState
tell application "Finder"
    if exists file (thisFolder & "STOP_CLICKING.txt") then
        set clickState to false
    else if exists file (thisFolder & "CLICKING.txt") then
        set clickState to true
    else
        set clickState to null
    end if
end tell
return clickState
end checkstate

#function to update state of clicking via text files
#im sure there is a better way, but this certainly works
on togglestate()
if checkstate() is null then
    tell application "Finder" to make new file at thisFolder with properties     {name:"CLICKING.txt"}
else if checkstate() is true then
    tell application "Finder" to make new file at thisFolder with properties {name:"STOP_CLICKING.txt"}
else if checkstate() is false then
    tell application "Finder"
        delete file (thisFolder & "CLICKING.txt")
        delete file (thisFolder & "STOP_CLICKING.txt")
    end tell
end if
end togglestate


togglestate()
#we dont really want 3 states so we'll toggle again after a reset
if checkstate() is null then togglestate()

if checkstate() is true then
tell application "Finder"
    open (thisFolder & "clicking_script")
end tell
end if

clicking_script.app

global thisFile
set thisFile to (path to me)

global thisFolder
tell application "Finder" to set thisFolder to container of thisFile as text


## Function to check current state / should we should stop clicking
on checkstate()
local clickState
tell application "Finder"
    if exists file (thisFolder & "STOP_CLICKING.txt") then
        set clickState to false
    else if exists file (thisFolder & "CLICKING.txt") then
        set clickState to true
    else
        set clickState to null
    end if
end tell
return clickState
end checkstate


# let the clicking begin
on crazyClick()
set x to 0
repeat until checkstate() = false or x = 1000
    do shell script ((POSIX path of thisFolder as text) & "mousetools -leftClick")
    do shell script ((POSIX path of thisFolder as text) & "mousetools -releaseMouse")
    set x to (x + 1)
    delay 0
end repeat
end crazyClick

crazyClick()

These two scripts need to be saved as applications. Once you have those three items in your folder all you have to do is assign launch.app as a custom application to be launched for a particular click using MagicPrefs.

When you activate the script it clicks like crazy until you activate it again, which breaks the loop by adding some empty text files to the folder. We used the text files as a simple way to have external variables.

I have zipped all the files for easy downloading.

It might not be perfect but its definitely a good start to seeing what creativeness can be accomplished with automation.

  • be careful running it without the shortcut setup. It clicks really fast and it might be difficult to break out out the loop if you cant launch the app again. The loop will always stop after 1000 clicks. So you can just wait a sec and it will stop. hope it helps – Eric Jones Feb 19 '15 at 7:47
  • @Jawa thanks for the edit. I think I was too tired to get the markdown working for a code block. Did this approach help you? – Eric Jones Feb 19 '15 at 16:52
  • Didn't try, no personal need but seems legit. – Jawa Feb 19 '15 at 18:33
  • Oh, I see now, I mistook you for the original asker. I was wondering why you were asking this question without much research, being as active on the site as you are. Well thank you for stopping by and doing edits for us. Have a great day sir. – Eric Jones Feb 19 '15 at 23:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .