Automate mouse click in windows with script/batch file Automate mouse click in windows with script/batch file windows windows

Automate mouse click in windows with script/batch file


Just in case some poor soul stumbles upon this one day, using AutoIt that @rojo suggested above - This is the script that I wrote that accomplishes what I need:

; Initiate ScriptMain()Func Main()    ; Infinite loop    While 0 < 1        If CheckTime() == true Then            If CheckInternetConnection() == true Then                ; Internet Connection is true                ; So no worries            Else                ; Internet Connection is false                ; Perform mouse click                MouseClick("left")            EndIf               EndIf        ; Sleep for 15 minutes        Sleep(60000 * 15)    WEndEndFunc; The function checks if the current time is between 00:00 and 05:00Func CheckTime()    If @Hour >= 00 AND @Hour <= 05 Then        Return true    Else        Return false    EndIfEndFunc; The function checks if currently is a internet connectionFunc CheckInternetConnection()    Local $Connected = false    $ping = Ping("www.google.com")    If $ping > 0 Then        $Connected = true    EndIf    Return $ConnectedEndFunc

And there you go, just save the code in a file with a .au3 file extention, double click and enjoy.


I'd use AutoIt. IMHO, autoit is more appropriate for running scripts where a systray icon might be preferable to a console window. AutoIt can check the time, ping something, automate a mouse click, and probably whatever else you need.


nircmd is capable to do some basic mouse stuff.Check mouse.bat - self-compiled C# class (c# compiler is installed by default from everything from vista and above) capable to command the mouse from command line (also pretty basic but can do a little bit more than nircmd). with mouse.bat -help you can see the help and some example actions.

here's example usage:

Examples:

::clicks at the current positioncall mouse click::double clicks at the current positioncall mouse doubleClick::right clicks at the current positioncall mouse rightClick::returns the position of the cursorcall mouse position::scrolls up the mouse wheel with 1500 unitscall mouse scrollUp 150::scrolls down with 100 postitionscall mouse scrollDown 100::relatively(from the current position) moves the mouse with 100 horizontal and 100 vertial postitionscall mouse moveBy 100x100::absolute positioningcall mouse moveTo 100x100::relative drag (lefclick and move)call mouse dragBy 300x200::absolute dragcall mouse dragTo 500x500