Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows command script that moves mouse cursor N pixels?

I am trying to find out how to move the mouse cursor N pixels to some direction.... through a command script, since I cannot install anything on my computer.

I basically try to keep the screen active forever, until I kill the script.

(Yes, I've been searching high and low for a way to do it by a command script.... but could not find anything. I hope it's possible.)

like image 608
rapt Avatar asked Dec 10 '12 19:12

rapt


People also ask

How do I move cursor in powershell?

To move the cursor one word to the left, press Ctrl + LeftArrow .

Does Autohotkey move mouse?

Speed is ignored for SendInput/Play modes; they move the mouse instantaneously (though SetMouseDelay has a mode that applies to SendPlay).


3 Answers

The most straightforward way to manipulate mouse with batch file is with

rundll32 user32.dll,SetCursorPos

But this is not very useful - just sets the mouse to 0,0 position.

Check the mouse.bat - it is a self compiled C#/batch file and does not require external tools and the source is visible and editable.

Examples:

//clicks at the current position
call mouse click

//double clicks at the current position
call mouse doubleClick

//right clicks at the current position
call mouse rightClick

//returns the position of the cursor
call mouse position

//scrolls up the mouse wheel with 1500 units
call mouse scrollUp 150

//scrolls down with 100 postitions
call mouse scrollDown 100

 //relatively(from the current position) moves the mouse with 100 horizontal and 100 vertial postitions
call mouse moveBy 100x100

//absolute positioning
call mouse moveTo 100x100

//relative drag (lefclick and move)
call mouse dragBy 300x200

//absolute drag
call mouse dragTo 500x500
like image 103
npocmaka Avatar answered Oct 13 '22 00:10

npocmaka


Search for NirCmd, and install it in C:\windows, and do:

nircmd setcursor 100 50
nircmd movecursor 10 10

or another commands for clicks etc.

like image 43
MoE Avatar answered Oct 13 '22 00:10

MoE


(Late answer but can still be useful for others) If you just want to keep your computer from falling asleep, the software "Caffeine" does this quite well.

like image 44
SharpNip Avatar answered Oct 13 '22 02:10

SharpNip