移动鼠标光标 N 像素的 Windows 命令脚本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13807543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows command script that moves mouse cursor N pixels?
提问by rapt
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.
我试图找出如何通过命令脚本将鼠标光标移动 N 个像素到某个方向......,因为我无法在我的计算机上安装任何东西。
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.)
(是的,我一直在寻找一种通过命令脚本来做到这一点的方法......但找不到任何东西。我希望这是可能的。)
回答by npocmaka
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.
但这不是很有用 - 只需将鼠标设置为 0,0 位置。
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.
检查mouse.bat- 它是一个自编译的 C#/批处理文件,不需要外部工具,源代码是可见的和可编辑的。
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
回答by MoE
Search for NirCmd, and install it in C:\windows, and do:
搜索NirCmd,并将其安装在C:\windows 中,然后执行:
nircmd setcursor 100 50
nircmd movecursor 10 10
or another commands for clicks etc.
或其他点击命令等。
回答by SharpNip
(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.
(迟到的答案,但对其他人仍然有用)如果您只是想让计算机不入睡,“Caffeine”软件可以很好地做到这一点。
回答by jelde015
You could try installing AutoHotKey. It makes controlling mouse very simple. Example script:
您可以尝试安装 AutoHotKey。它使控制鼠标变得非常简单。示例脚本:
#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.
运行此示例的脚本后,按 control+g,它将每秒单击一次以保持屏幕唤醒。再次 ctrl+g 停止。
install at: https://www.autohotkey.com/
安装在:https: //www.autohotkey.com/
found solution: https://autohotkey.com/boards/viewtopic.php?t=19846