将鼠标光标移动N个像素的Windows命令脚本?

rap*_*apt 9 windows batch-file

我试图找出如何通过命令脚本将鼠标光标N像素移动到某个方向....因为我无法在我的计算机上安装任何东西.

我基本上试图让屏幕保持活跃,直到我杀死脚本.

(是的,我一直在寻找一种通过命令脚本执行此操作的方法......但是找不到任何东西.我希望它是可能的.)

npo*_*aka 15

使用批处理文件操作鼠标的最简单方法是使用

rundll32 user32.dll,SetCursorPos
Run Code Online (Sandbox Code Playgroud)

但这不是很有用 - 只需将鼠标设置为0,0位置即可.

检查mouse.bat - 它是一个自编译的C#/批处理文件,不需要外部工具,源可见且可编辑.

例子:

//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
Run Code Online (Sandbox Code Playgroud)

  • 你知道 Windows 10 x64 相当于这个吗?`rundll32 user32.dll,SetCursorPos` (2认同)

小智 13

搜索NirCmd,并将其安装在C:\ windows中,并执行:

nircmd setcursor 100 50
nircmd movecursor 10 10
Run Code Online (Sandbox Code Playgroud)

或点击等的其他命令


小智 5

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