VB脚本设置光标位置
我正在寻找一种在计算机启动后通过脚本设置光标位置的简单方法。
我发现:
Private Declare Sub SetCursorPos Lib "User32" (ByVal X As Long, ByVal Y As Long)
SetCursorPos 4, 52
但是无法在 VBScript 中使用它们......
有更好的解决方案吗?我怎样才能做到这一点而无需编译应用程序?
预先感谢您的帮助!
I'm looking for a simple way of setting the cursor position by script, after computer start.
I've found :
Private Declare Sub SetCursorPos Lib "User32" (ByVal X As Long, ByVal Y As Long)
SetCursorPos 4, 52
But can't manage to use them in a VBScript for example...
Is there a better solution ? How can I do this without having to compile an application ?
Thanks in advance for your help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,遗憾的是您无法直接从 VBScript 调用 Windows API 函数。考虑到直接调用本机代码的脚本语言的安全隐患,以及除
Variant
之外缺乏任何数据类型,这是不可能的。一种方法是创建某种辅助自动化对象来调用 API,然后您可以从 VBScript 中使用它。
但这对于一次性任务来说是一项巨大的工作量。我建议用您熟悉的任何语言来编译应用程序。如果您可以用 VBScript 编写,您也可以用 VB 6 编写...如果您仍然可以找到编译器/IDE 的副本。
No, unfortunately you cannot call Windows API functions directly from VBScript. Given the security implications of a scripting language calling down to native code directly, and the lack of any data types other than
Variant
, there's no way this can work.One way to do it is to create some kind of helper automation object to call the API, which you can then use from VBScript.
But that's an awful lot of work for a one-off task. I'd suggest just compiling an application in whatever language you're comfortable in. If you can write in VBScript, you can write in VB 6...if you can still find a copy of the compiler/IDE.
您需要定义 setCursorPos
VBS-Helper
(发布于 15:09 GMT)
You need to define setCursorPos
VBS-Helper
(Posted at 15:09 GMT)
这是一个 Excel 代码,可以正常工作。 仅在 vbscript 中尝试!
This is a excel code, this is working. Try it in vbscript only!