简体   繁体   中英

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.)

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

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.

(迟到的答案,但对其他人仍然有用)如果您只是想让计算机不入睡,“Caffeine”软件可以很好地做到这一点。

You could try installing AutoHotKey. It makes controlling mouse very simple. Example script:

#MaxThreadsPerHotkey 3

^g::
Toggle := !Toggle
Loop
{
    If (!Toggle)
        Break
    Click
    Sleep 1000 ; Make this number higher for slower clicks, lower for faster.
}
Return

After running script for this example press control+g and it will click every second to keep screen awake. ctrl+g again to stop.

install at: https://www.autohotkey.com/

found solution: https://autohotkey.com/boards/viewtopic.php?t=19846

try setting sleep mode to 'none', but if you want to move your mouse without even touching it, download memz clean and let the "random cursor movement" to be bluish. now enjoy. (if it doesn't work, the payloads must be disabled. try doing shift+esc to enable/disable payloads. try doing ctrl+shift+s to skip some time because in some minutes the mouse will shake more better.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM