Windows command script that moves mouse cursor N pixels?

前端 未结 4 552
别跟我提以往
别跟我提以往 2020-12-05 08:39

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 basic

相关标签:
4条回答
  • 2020-12-05 09:15

    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
    
    0 讨论(0)
  • 2020-12-05 09:28

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

    0 讨论(0)
  • 2020-12-05 09:28

    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

    0 讨论(0)
  • 2020-12-05 09:35

    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.

    0 讨论(0)
提交回复
热议问题