VB脚本设置光标​​位置

发布于 2024-12-21 23:01:54 字数 270 浏览 3 评论 0原文

我正在寻找一种在计算机启动后通过脚本设置光标​​位置的简单方法。

我发现:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

瑾兮 2024-12-28 23:01:54

不,遗憾的是您无法直接从 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.

飘然心甜 2024-12-28 23:01:54

您需要定义 setCursorPos

VBS-Helper
(发布于 15:09 GMT)

You need to define setCursorPos

VBS-Helper
(Posted at 15:09 GMT)

傲娇萝莉攻 2024-12-28 23:01:54

这是一个 Excel 代码,可以正常工作。 仅在 vbscript 中尝试!

Dim Excel: Set Excel = WScript.CreateObject("Excel.Application")
Excel.ExecuteExcel4Macro "CALL(""user32"",""SetCursorPos"",""JJJ""," & 320 & "," & 2 & ")"

This is a excel code, this is working. Try it in vbscript only!

Dim Excel: Set Excel = WScript.CreateObject("Excel.Application")
Excel.ExecuteExcel4Macro "CALL(""user32"",""SetCursorPos"",""JJJ""," & 320 & "," & 2 & ")"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文