nircmd - 强大windows命令行工具之鼠标操作

nircmd是windows一个强大小巧精悍的命令行工具;

这篇文章只介绍使用nircmd才完成操作鼠标常用的方法:

鼠标命名操作方法
sendmouse [right | left | middle] [down | up | click | dblclick]

sendmouse [move] [x] [y]

sendmouse [wheel] [Wheel Value]

Sends the specified mouse event to the system. The operating system will behave exactly as the user really made the specified mouse action. 
Heres some example of sendmouse command:
Sent a right click (For most applications, a context menu is opened): 
sendmouse right click
Sent a double-click with the left mouse button: 
sendmouse left dblclick
Press the left mouse button, move the mouse cursor 20 pixels left and 30 pixels down, and then release the button: 
sendmouse left down 
sendmouse move -30 20 
sendmouse left up
Scroll the mouse wheel 10 units in standard wheel mouse. (On standard wheel mouse, the wheel value should be a multiple of 120). 
sendmouse wheel 1200


这里结合vbs来调用nircmd举例:

鼠标定位:
Set sh  = CreateObject("WScript.Shell")
sh.run("nircmd setcursor x y", 0, true); 


按下鼠标左键:
Set sh  = CreateObject("WScript.Shell")
sh.run("nircmd sendmouse left down", 0, true);



鼠标拖拽:注意鼠标拖拽要结合鼠标定位,按下鼠标左键,执行鼠标拖拽,抬起鼠标这一系列操作;
Set sh  = CreateObject("WScript.Shell")
sh.run("nircmd sendmouse move moveX moveY", 0, true);


抬起鼠标左键:
Set sh  = CreateObject("WScript.Shell")
sh.run("nircmd sendmouse left up", 0, true);


向下滚动鼠标滚轮:
Set sh  = CreateObject("WScript.Shell")
sh.run("nircmd sendmouse wheel -1000", 0, true);


更多命令,请查阅nircmd命令参考
http://nircmd.nirsoft.net/

你可能感兴趣的:(windows nircmd)