找回密码
 加入
搜索
查看: 1380|回复: 3

下拉框问题

[复制链接]
发表于 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,菜鸟一只请大家指点
发表于 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 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
发表于 2009-6-7 14:17:22 | 显示全部楼层
x学习了,留名啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 03:11 , Processed in 0.082333 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表