Automatic mouse clicks in Windows

Sac Arrow

Touchdown! Greaser!
PoA Supporter
Joined
May 11, 2010
Messages
20,698
Location
Charlotte, NC
Display Name

Display name:
Snorting his way across the USA
I want to be able to have my mouse make automatic clicks at timed intervals. I know it can be done. I Googled, but I suck at scripting and don't want to download some third party software if I don't have to. Anyone have a script to share that can accomplish that? Just a single mouse click, that can run in Task Scheduler. Or a better way to do that, if there is one.
 
No I don't need to move the mouse, I just want it to click every ten minutes until I don't want it to.
 
C'mon man - the FIRC isn't *that* bad.
 
The Mouse Jiggler MJ-3 is programmable, to include mouse clicks. Setup is very easy.


Available at Amazon and other fine retailers.
 
I just want something simple and stupid.
 
powershell or power automate

1721088895886.png

I thank myself.
 
post #2 beat me to it, but yes, Wells Fargo approves of this thread. :biggrin:
 
I want to be able to have my mouse make automatic clicks at timed intervals. I know it can be done. I Googled, but I suck at scripting and don't want to download some third party software if I don't have to. Anyone have a script to share that can accomplish that? Just a single mouse click, that can run in Task Scheduler. Or a better way to do that, if there is one.
Why?
 
Spiral ramp that periodically drops a ball bearing on the mouse button? Geared cam?
 
Put the code in a file and call it say mouse-clicks.ps1
The .ps1 suffix is VITAL.

Use Explorer (file explorer) and right click on the file
Choose - Run with Powershell
After 5 seconds it will click once every 5 seconds, 8 times.
Change the 5 and 8 numbers to get behaviour you want.

I got some cryptic message about security, I pressed S (then [Return] I think) in desperation. (Suspend)

Seems to work. You move the cursor to where you want the mouse clicks and it clicks away.

I have no idea what security I suspended.

To stop it move the cursor to the powershell window and close it
One thing that can go wrong is that the click could occur on the powershell window (or the self destruct button). This will freeze the output and suspend the script. A rectangular block cursor will appear. Either close and start again, or press escape key when the window has the Input focus.

[Ctrl]C will stop the script and the window will close. Input focus has to be in the PowerShell window.

Remove the "Write-Host " line if you don't like it displaying how many it has done so far. I put it in to convince myself that something was happening. When it was running I put the cursor over a menu item in notepad and it was clicking away.

Tested on Windows 10.

Code:
#import mouse_event
Add-Type -MemberDefinition '[DllImport("user32.dll")] public static extern void mouse_event(int flags, int dx, int dy, int cButtons, int info);' -Name U32 -Namespace W;

for ($var = 1; $var -le 8; $var++) {

Start-Sleep -Seconds 5

##left mouse click
[W.U32]::mouse_event(6,0,0,0,0);

Write-Host The value of Var is: $var



## COMMENTED OUT SECTION
## For use if you want to move the mouse
##move 10% along x and 10% along y and send left mouse click
####[W.U32]::mouse_event(0x02 -bor 0x04 -bor 0x8000 -bor 0x01, .1*65535, .1 *65535, 0, 0);

}
 
Last edited:
Or just use the bit bucket output of a Signetics 25120 Write-Only Memory.

Signetics 25120 P1.jpg


Signetics 25120 P2.jpg


Joking aside, I've used the application linked below when I had to keep hitting refresh every second to monitor some parameters in a buggy application that couldn't be coerced to auto-update.
 
Back
Top