gpt4 book ai didi

.net - 读取按钮的 'Enabled' 状态

转载 作者:行者123 更新时间:2023-12-04 23:25:25 25 4
gpt4 key购买 nike

如何在 AutoIt 中获得 Enabled 状态按钮(禁用/变暗或启用)?它确实适用于属性Text,但似乎不适用于属性(无论按钮的状态如何,结果总是相同)已启用(Visual Studio 中 .NET Windows 窗体意义上的“属性”)。

这适用于 .NET 应用程序(Windows 窗体、VB.NET),其中 Visual Studio 设计器中的按钮名称是 btnStoreInModule,属性文本是 S&tore in Module。属性(property)Enabled是我感兴趣的。按钮的类型是System.Windows.Forms.Button .我的 AutoIt 脚本像这样按下按钮:

ControlClick("My Application", "", "[NAME:btnStoreInModule]")

应用程序通过在执行操作时禁用按钮来响应。操作完成后,该按钮将再次启用(未变暗)。 Store 按钮被禁用时的应用:

Button in a disabled state. For a .NET application

AutoIt Window Information Tool为禁用和启用状态提供相同的结果:

>>>> Window <<<<
Title: My Application 1.2a6
Class: WindowsForms10.Window.8.app.0.b7ab7b
Position: -4, 34
Size: 1448, 870
Style: 0x17CF0000
ExStyle: 0x00050100
Handle: 0x000C08DE

>>>> Control <<<<
Class: WindowsForms10.BUTTON.app.0.b7ab7b
Instance: 21
ClassnameNN: WindowsForms10.BUTTON.app.0.b7ab7b21
Name: btnStoreInModule
Advanced (Class): [NAME:btnStoreInModule]
ID: 592026
Text: S&tore in Module
Position: 257, 675
Size: 91, 23
ControlClick Coords: 59, 8
Style: 0x5601000B
ExStyle: 0x00000000
Handle: 0x0009089A

可以使用(TB_Type 是 Visual Studio 属性窗口中文本框的名称(属性 “名称”)):

Local $sText = ControlGetText ("My Application", "", "[NAME:TB_Type]")

对于按钮,相应的行返回 S&tore in Module(正如人们所期望的那样)。

AutoIt 版本:3.3.8.1 (2012-01-29)。

最佳答案

使用 ControlCommand像这样的功能:

    $isControlEnabled = ControlCommand($hWin, "", "[NAME:button2]", "IsEnabled", "")

如果 "[NAME:button2]" 启用,该函数将返回 => 1,如果禁用,则返回 0。

关于.net - 读取按钮的 'Enabled' 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13860223/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com