题
我在用 自动它 创建自动安装应用程序。有一个对话框,其中包含一个列表框控件,列表框中有一些供用户选择的选项(具体选择取决于用户的机器。对于某些用户来说可能只有一种选择,对于某些用户可能有三种选择,等等),所以我想获取列表框中的文本来做出决定。我已经尝试过以下代码,但它不起作用。
; 2223 is the ID of listbox
$txt = ControlGetText("Select Web Site", "", "[ID:2223]")
Msgbox(0, "", $txt)
执行后 $txt
一片空白。
那么我应该怎么做才能获取Listbox中的文本呢?
这是监听的列表框的属性 AutoIt v3 窗口信息:
Class: WindowsForms10.Listbox.app.0.33c0d9d
解决方案 4
我要做的是在列表中选择一个名为“默认网站”的项目,但是看来列表内容无法获得,所以最后我尝试了另一种方法:
首先,我将列表框重点放在以上,然后通过发送“ def”:“默认网站”:
ControlFocus($Title, "", "[NAME:lbWebSites]")
; Select the option "Default Web Site", so press "def" to set the desired item.
Send("Def")
其他提示
我发现“ send”命令有时是不可靠的,尤其是如果PC被锁定。
“ ControlSend”一直在努力获取我想要的击键。
我编写了一个测试来检查某个项目是否在组合框中。使用 GuiComboBox.au3 的列表框可能有类似的功能。
Func DoesItemExistInComboBox($windowtitle, $windowtext, $comboboxcontrol, $itemtocheck)
$returnvalue = 0
$ComboBoxHandle = ControlGetHandle($windowtitle, $windowtext, $comboboxcontrol)
$ComboBoxArray = _GUICtrlComboBox_GetListArray($ComboBoxHandle)
For $i = 0 TO UBound($ComboBoxArray)-1
If $ComboBoxArray[$i] = $itemtocheck Then
$returnvalue = 1
EndIf
Next
return $returnvalue
EndFunc
关于什么:
ControlCommand("My GUI", "", "[CLASS:ListBox; INSTANCE:1]", "SelectString", "item2")
不隶属于 StackOverflow