在 AutoIt 中使用窗口文本和标题设置控制文本

发布于 2024-10-16 14:33:32 字数 896 浏览 6 评论 0原文

我是 autoit 的新手。我有 2 个问题。

  1. 当窗口没有文本且没有标题时,如何使用 ControlFocus ( "", "", "[X:643;Y:339]" )。请查看窗口通知者查看的窗口和控件的以下信息。
<块引用> <块引用> <块引用>

窗口<<<<< 标题: 类:WindowsForms10.Window.8.app.0.33c0d9d 位置: 0, 0 尺寸:1024、768 风格:0x16010000 示例样式:0x00010000 句柄:0x005201E0

控制<<<< 类:WindowsForms10.EDIT.app.0.33c0d9d 实例:2 类名NN:WindowsForms10.EDIT.app.0.33c0d9d2 姓名:txt消费者编号 高级(班级):[名称:txtConsumerNo] 编号:15270262 文本: 位置:638、237 尺寸:263、30 ControlClick 坐标:38、27 风格:0x560100C0 示例样式:0x00000200 句柄:0x00E90176

如何与此控件交互?

  1. 我想调用此控件的文本更改事件。怎么可能

I am quite newbie to autoit. I have 2 questions.

  1. How to use ControlFocus ( "", "", "[X:643;Y:339]" ) when widow has no text and no title.Please look at following information of window and control viewed by window informer.

Window <<<<
Title:
Class: WindowsForms10.Window.8.app.0.33c0d9d
Position: 0, 0
Size: 1024, 768
Style: 0x16010000
ExStyle: 0x00010000
Handle: 0x005201E0

Control <<<<
Class: WindowsForms10.EDIT.app.0.33c0d9d
Instance: 2
ClassnameNN: WindowsForms10.EDIT.app.0.33c0d9d2
Name: txtConsumerNo
Advanced (Class): [NAME:txtConsumerNo]
ID: 15270262
Text:
Position: 638, 237
Size: 263, 30
ControlClick Coords: 38, 27
Style: 0x560100C0
ExStyle: 0x00000200
Handle: 0x00E90176

How is it possible to interact with this control?

  1. I want to call text change event of a this control. How is it possible

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

甜扑 2024-10-23 14:33:32

如果您正在处理没有文本和标题的窗口,那么首先使用 WinGetHandle 获取窗口句柄可能会更容易。您可以从活动窗口获取句柄,如下所示:

$hWnd = WinGetHandle("[ACTIVE]")

为了与控件交互,您有很多选项。您最好的选择可能是使用控件的名称,即:txtConsumerNo。如果您像这样使用 ControlFocus ,它就会起作用。请注意,$hWnd 来自上面的 WinGetHandle 语句。

ControlFocus($hWnd, "", "[NAME:txtConsumerNo]")

我建议不要使用控件的 X 和 Y 位置。它可能很难找到正确的控制。当其他方法可用时,例如名称或类,这些方法是非常首选的。

您可以使用 ControlSetText 方法更改 AutoIt 中另一个控件的文本。它会自动为您调用“文本更改事件”。有关 ControlSetText 的文档,请参阅帮助文件。它的工作方式与 ControlFocus 类似。

If you are dealing with a window without text and a title, it may be easier to first get the handle to the window with WinGetHandle. You can get the handle from the active window like so:

$hWnd = WinGetHandle("[ACTIVE]")

For interacting with the control you have a lot of options. Your best option is probably to use the Name of the control, which is: txtConsumerNo. If you then use ControlFocus like so it will work. Note that $hWnd comes from the above WinGetHandle statement.

ControlFocus($hWnd, "", "[NAME:txtConsumerNo]")

I recommend against using the X and Y position of the control. It can have a hard time finding the correct control. When other methods are available, such as the name or the class, those are very much preferred.

You can change the text of another control in AutoIt with the ControlSetText method. It will call the 'text change event' for you automatically. See the help file for the documentation about ControlSetText. It works in a similar way to ControlFocus.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文