How to Move the mouse using VBScript

点点圈 提交于 2019-12-02 07:22:22

问题


I am trying to move the mouse using VBScript. I tried to use Sendkeys "{CLICK LEFT , x , y}" and Sendkeys "{MOVETO, 10 , 20}" but it isn't working i also tried to use MouseKeys, so i could move it with the keyboard and therefore use Sendkeys to activate it but it also did not work (the mousekeys numpad is not moving the mouse). I've tried everything I know and what i could research elsewhere, so now I hope one of you can answer this for me. thxs


回答1:


VBScript can't do this natively. You'd have to do some calls to the Windows API or some other library that can do this for you.

As an alternative, you may want to consider a different scripting language, like AutoHotKey which can do this in one simple line of code for you.




回答2:


One possible way to move the mouse is:

Dim Excel: Set Excel = WScript.CreateObject("Excel.Application") 
Excel.ExecuteExcel4Macro "CALL(""user32"",""SetCursorPos"",""JJJ"",""xxx"",""yyy"")"

-->xxx = X Position | yyy = y Position

The only disadvantage is that you need Microsoft Excel to run this script...

Hope I could help you



来源:https://stackoverflow.com/questions/33019106/how-to-move-the-mouse-using-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!