kkkpep 发表于 2009-6-7 10:39:48

下拉框问题

菜鸟问个问题,以下如何编写

首先运行一段批处理
会返回几行(不定)数据,比如:(括号中数字是随机无效的)
abc:2214556 (1234g)
abc:15466 (11246)
abc:1214646 (122135456)
abc:214646 (212354)
将这几行以下拉框的形式显示并移除大于2000000(冒号后括号前的)的
用户选择后
再以参数运行程序a
如下
a.exe abc:21646 -q

本人初涉au3,菜鸟一只请大家指点

lynfr8 发表于 2009-6-7 13:05:30

本帖最后由 lynfr8 于 2009-6-7 13:06 编辑

思路:
1.正则获取所需字段,再进行数值大小判断筛选有效数据
2.返回有效数据到combo
3.读取combo所选数据,赋值到run运行程序

效果图:

#include <Array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBoxEx.au3>
$Form1 = GUICreate("正则判断", 321, 228, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 16, 8, 289, 113)
GUICtrlSetData($Edit1, 'abc:2214556 (1234g)abc:15466 (11246)abc:1214646 (122135456)abc:214646 (212354)')
$Combo1 = GUICtrlCreateCombo("获取参数", 176, 168, 97, 25)
$Button1 = GUICtrlCreateButton("运行正则", 192, 136, 65, 25, 0)
$Button2 = GUICtrlCreateButton("运行参数", 191, 197, 65, 25, 0)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$a=GUICtrlRead($Edit1)
$b = stringRegExp($a,'.{3}:(\d{0,7})',3)
for $i = 0 to UBound($b) - 1
If $b[$i] <2000000 Then
GUICtrlSetData ($Combo1,$b[$i])
EndIf
Next
Case $Button2
$c=GUICtrlRead($Combo1)
run('a.exe abc:'&$c&' -q')
MsgBox('','','已经运行a.exe abc:'&$c&' -q')
EndSwitch
WEnd

lynfr8 发表于 2009-6-7 13:10:46

本帖最后由 lynfr8 于 2009-6-7 13:12 编辑

$a=GUICtrlRead($Edit1)
;读取数据
$b = stringRegExp($a,'.{3}:(\d{0,7})',3)
;正则表达式,其中 .{3}:代表任意三个字母和:   (\d{0,7}) 括号内为需要获取的字段,\d{0,7} 表示任意0-7位数的数字
for $i = 0 to UBound($b) - 1
;循环读取返回的数组
If $b[$i] <2000000 Then
;判断<2000000 的有效数值
GUICtrlSetData ($Combo1,$b[$i])
;将有效数值写入combo

kn007 发表于 2009-6-7 14:17:22

x学习了,留名啊
页: [1]
查看完整版本: 下拉框问题