找回密码
 加入
搜索
查看: 5438|回复: 9

[AU3基础] 如何得到下拉选项的结果?

  [复制链接]
发表于 2010-2-8 20:53:43 | 显示全部楼层 |阅读模式
$Combo1 = GUICtrlCreateCombo('Select version of vcf card',80,15,150,20)
GUICtrlSetData(-1, "aaa|bbb")
.
那么后面我能不能用
$R=GUICtrlRead($Combo1)
If $R = 'aaa' then xxxx
If $R = 'bbb' then xxxx
我试了试好像是错的呢。希望得到大家的帮助,谢谢
发表于 2010-2-8 21:54:21 | 显示全部楼层
回复 1# xavier880819
$oForm = _IEFormGetObjByName ($oIE, "form1")
$oSelect = _IEFormElementGetObjByName ($oForm, "LoginServer")
For $i = 1 To 2   
 _IEFormElementOptionSelect ($oSelect, "铁血一区(电信区)", 1, "byText")
Next
 楼主| 发表于 2010-2-9 09:00:55 | 显示全部楼层
回复 2# jtw


楼上的回答貌似不对吧???
发表于 2010-2-9 10:06:00 | 显示全部楼层
加入响应事件
 楼主| 发表于 2010-2-9 10:58:43 | 显示全部楼层
回复 4# jhwl


请问怎么加入响应事件呢??能不能根据我所说的例子给个详细点的解答??我不是很能明白。
发表于 2010-2-9 11:37:41 | 显示全部楼层
_GUICtrlComboBox_GetEditText($Combo1)
 楼主| 发表于 2010-2-9 11:43:17 | 显示全部楼层
下面是我的全部代码,现在是我加了下拉的选项之后就不能工作了,希望大家可以帮忙看看怎么回事
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <File.au3>
#NoTrayIcon

Opt('MustDeclareVars', 1)

GUICreate('v1', 310, 180, -1, -1)

Dim $p, $Button, $Button2, $nMsg,$i,$Str,$InputNum,$l1,$l2,$Radio1,$Radio2,$Combo1,$p2,$Button3,$ywxx,$Str2,$R,$p3

$p = GUICtrlCreateInput("0", 100, 105, 70, 20)
$p2 = GUICtrlCreateInput("", 35, 45, 170, 20)
$Button = GUICtrlCreateButton("创建联系人", 180, 105, 110, 20)
$Button2 = HotKeySet("{ESC}","Terminate")
$Button3 = GUICtrlCreateButton("目标文件夹", 210, 45, 80, 20)
$Radio1 = GUICtrlCreateRadio('前缀 000',20,90)
$Radio2 = GUICtrlCreateRadio('无前缀',20,110)
$Combo1 = GUICtrlCreateCombo('请选择版本',80,15,150,20)
GUICtrlSetData(-1, "2.1|3.0")
$l1 = GUICtrlCreateLabel('输入数目',35,70,250,15)
$l2 = GUICtrlCreateLabel("按'Esc'来终止程序",55,150,250,15)
GUICtrlSetColor(-1, 0xff0000)

GUISetState()
While 1
     $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                Case $Button2
                                                Terminate()
                                Case $Button3
                        $ywxx = FileSelectFolder("选择文件夹", "", 4)
                        If @error Then ContinueLoop
                        GUICtrlSetData($p2, $ywxx)
                                Case $Button
                                     Switch $R=GUICtrlRead($Combo1)
                                          Case '2.1'
                                
                                          If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) Then Create()
                                          If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) Then Create2()        
                              
                                          Case  '3.0'
                                                          
                                                If        BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) Then Create4()
                                                  
                                     If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) Then Create3()
                                EndSwitch
                
                                        
    EndSwitch
WEnd

Func Terminate()
                    Exit 0
EndFunc   ;==>Terminate

Func Create()
                $InputNum=GUICtrlRead($p)
                $p3=GUICtrlRead($p2)
        For $i=1 to $InputNum step 1
        $Str = 'BEGIN:VCARD'&@CRLF&'VERSION:2.1'&@CRLF&'N;LANGUAGE=zh-sg:Contact'&$i&@CRLF&'FN:Contact' &$i&@CRLF&'ORG:Creative'&$i&';'&'PDE'&$i&@CRLF&'TITLE:SQA'&$i&@CRLF&'TEL;WORK;VOICE:B 00000'&$i&@CRLF&'TEL;HOME;VOICE:H 00000'&$i&@CRLF&'TEL;CELL;VOICE:M 00000'&$i&@CRLF&'TEL;WORK;FAX:BF 00000'&$i&@CRLF&'ADR;WORK;PREF:;;SQA Road;Creative;PDE;00000'&$i&';Singapore'&@CRLF&'LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE:SQA Road=0D=0A='&@CRLF&'Creative  PDE  00000'&$i&@CRLF&'X-MS-OL-DEFAULT-POSTAL-ADDRESS:2'&@CRLF&'URL;WORK:www.contact'&$i&'.com'&@CRLF&'EMAIL;PREF;INTERNET:Contact'&$i&'@hotmail.com'&@CRLF&'X-MS-IMADDRESS:Contact'&$i&'@hotmail.com'&@CRLF&'X-MS-CARDPICTURE;TYPE=JPEG;ENCODING=BASE64:'&@CRLF&' /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQY'&@CRLF&' GBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYa'&@CRLF&' KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAAR'&@CRLF&' CACUACcDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA'&@CRLF&' AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK'&@CRLF&' FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG'&@CRLF&' h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl'&@CRLF&' 5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA'&@CRLF&' AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYk'&@CRLF&' NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE'&@CRLF&' hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk'&@CRLF&' 5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD6UdwpAPU0oIwSTxVeQ7nOPoKRj2B4FAEk'&@CRLF&' k4/g59zREMgk9fWoFGSKsr8qc+maAIJfmlx6cUUkIy5aigBw4yfSkpT93680lABEMtUs52xk'&@CRLF&' evFJAOabcHkLQAkZ2R570Uk3CqtFACt14pKO1A6/SgCxCPlzVc/NN+NWT8kf0FVoeWJoASY5'&@CRLF&' fHpRTHbLE+9FAEnanRDkU3tU0I/ligBLhsIB61Gnyxk+tLcHLgegoKkqFXk8ZoAr0VMI0Xlz'&@CRLF&' z6UUAKOTipozhRjknmkDRnovP0oclUJHFACGMbsvyT2FMkkIwFG2kiyWJPJApkhBc+lACINz'&@CRLF&' fMaKaBk4FFAFmIfMPzpZz0H406JflJ/CmSMu88ZI456CgBIgQufeo8Kv3jk+gqVyfLwcDgDi'&@CRLF&' oKAAuei4Ue1FMooA0TwmT2qoBuYe9WZjiM+9QR9SfQUAEx4A7HJqKny/fx6cUygBlFFFAFu4'&@CRLF&' PIHpTYuF57mkkOWanHhPoP50AQk5JNJQetFADKKKKALQfcQCOtOcqRzjmmR9SfQUknUD0FAB'&@CRLF&' sU9P0NMMfv8AmKaetAYjoSKAAo2OOfoaKN57gH8KKAJ0+434Ux/vt9aKKAIz1ooooAZRRRQB'&@CRLF&' /9k='&@CRLF&''&@CRLF&'X-MS-OL-DESIGN;CHARSET=utf-8:<card xmlns="http://schemas.microsoft.com/office/outlook/12/electronicbusinesscards" ver="1.0" layout="left" bgcolor="ffffff"><img xmlns="" align="fit" area="16" use="cardpicture"/><fld xmlns="" prop="name" align="left" dir="ltr" style="b" color="000000" size="12"/><fld xmlns="" prop="org" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="title" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="dept" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="telwork" align="left" dir="ltr" color="000000" size="10"><label align="left" color="626262">Work</label></fld><fld xmlns="" prop="telcell" align="left" dir="ltr" color="000000" size="10"><label align="left" color="626262">Mobile</label></fld><fld xmlns="" prop="telhome" align="left" dir="ltr" color="000000" size="10"><label align="left" color="626262">Home</label></fld><fld xmlns="" prop="email" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="addrwork" align='&@CRLF&'"left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="webwork" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/></card>'&@CRLF&'REV:20100205T072550Z'&@CRLF&'END:VCARD'
        FileWrite($p3&'\'&'Contact' &'00'& $i & '.vcf', $Str)
        Next        
EndFunc

Func Create2()
                $InputNum=GUICtrlRead($p)
                $p3=GUICtrlRead($p2)
        For $i=1 to $InputNum step 1
        $Str = 'BEGIN:VCARD'&@CRLF&'VERSION:2.1'&@CRLF&'N;LANGUAGE=zh-sg:Contact'&$i&@CRLF&'FN:Contact' &$i&@CRLF&'ORG:Creative'&$i&';'&'PDE'&$i&@CRLF&'TITLE:SQA'&$i&@CRLF&'TEL;WORK;VOICE:B 00000'&$i&@CRLF&'TEL;HOME;VOICE:H 00000'&$i&@CRLF&'TEL;CELL;VOICE:M 00000'&$i&@CRLF&'TEL;WORK;FAX:BF 00000'&$i&@CRLF&'ADR;WORK;PREF:;;SQA Road;Creative;PDE;00000'&$i&';Singapore'&@CRLF&'LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE:SQA Road=0D=0A='&@CRLF&'Creative  PDE  00000'&$i&@CRLF&'X-MS-OL-DEFAULT-POSTAL-ADDRESS:2'&@CRLF&'URL;WORK:www.contact'&$i&'.com'&@CRLF&'EMAIL;PREF;INTERNET:Contact'&$i&'@hotmail.com'&@CRLF&'X-MS-IMADDRESS:Contact'&$i&'@hotmail.com'&@CRLF&'X-MS-CARDPICTURE;TYPE=JPEG;ENCODING=BASE64:'&@CRLF&' /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQY'&@CRLF&' GBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYa'&@CRLF&' KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAAR'&@CRLF&' CACUACcDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA'&@CRLF&' AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK'&@CRLF&' FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG'&@CRLF&' h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl'&@CRLF&' 5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA'&@CRLF&' AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYk'&@CRLF&' NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE'&@CRLF&' hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk'&@CRLF&' 5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD6UdwpAPU0oIwSTxVeQ7nOPoKRj2B4FAEk'&@CRLF&' k4/g59zREMgk9fWoFGSKsr8qc+maAIJfmlx6cUUkIy5aigBw4yfSkpT93680lABEMtUs52xk'&@CRLF&' evFJAOabcHkLQAkZ2R570Uk3CqtFACt14pKO1A6/SgCxCPlzVc/NN+NWT8kf0FVoeWJoASY5'&@CRLF&' fHpRTHbLE+9FAEnanRDkU3tU0I/ligBLhsIB61Gnyxk+tLcHLgegoKkqFXk8ZoAr0VMI0Xlz'&@CRLF&' z6UUAKOTipozhRjknmkDRnovP0oclUJHFACGMbsvyT2FMkkIwFG2kiyWJPJApkhBc+lACINz'&@CRLF&' fMaKaBk4FFAFmIfMPzpZz0H406JflJ/CmSMu88ZI456CgBIgQufeo8Kv3jk+gqVyfLwcDgDi'&@CRLF&' oKAAuei4Ue1FMooA0TwmT2qoBuYe9WZjiM+9QR9SfQUAEx4A7HJqKny/fx6cUygBlFFFAFu4'&@CRLF&' PIHpTYuF57mkkOWanHhPoP50AQk5JNJQetFADKKKKALQfcQCOtOcqRzjmmR9SfQUknUD0FAB'&@CRLF&' sU9P0NMMfv8AmKaetAYjoSKAAo2OOfoaKN57gH8KKAJ0+434Ux/vt9aKKAIz1ooooAZRRRQB'&@CRLF&' /9k='&@CRLF&''&@CRLF&'X-MS-OL-DESIGN;CHARSET=utf-8:<card xmlns="http://schemas.microsoft.com/office/outlook/12/electronicbusinesscards" ver="1.0" layout="left" bgcolor="ffffff"><img xmlns="" align="fit" area="16" use="cardpicture"/><fld xmlns="" prop="name" align="left" dir="ltr" style="b" color="000000" size="12"/><fld xmlns="" prop="org" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="title" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="dept" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="telwork" align="left" dir="ltr" color="000000" size="10"><label align="left" color="626262">Work</label></fld><fld xmlns="" prop="telcell" align="left" dir="ltr" color="000000" size="10"><label align="left" color="626262">Mobile</label></fld><fld xmlns="" prop="telhome" align="left" dir="ltr" color="000000" size="10"><label align="left" color="626262">Home</label></fld><fld xmlns="" prop="email" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="addrwork" align='&@CRLF&'"left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="webwork" align="left" dir="ltr" color="000000" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/><fld xmlns="" prop="blank" size="10"/></card>'&@CRLF&'REV:20100205T072550Z'&@CRLF&'END:VCARD'
        FileWrite($p3&'\'&'Contact' & $i & '.vcf', $Str)
        Next        
EndFunc

Func Create3()
        $InputNum=GUICtrlRead($p)
        $p3=GUICtrlRead($p2)
        For $i=1 to $InputNum step 1
        $Str2 = 'BEGIN:VCARD'&@CRLF&'VERSION:3.0'&@CRLF&'UID:00000000DE68105447DED646B28E5393F7B7F46224C02000'&@CRLF&'FN;CHARSET=UTF-8:Contact'&$i&@CRLF&'N;CHARSET=UTF-8:Contact'&$i&';;;;'&@CRLF&'ADR;TYPE=WORK;CHARSET=UTF-8:;;SQA Road;Creative;PDE;00000'&$i&';Singapore'&@CRLF&'LABEL;TYPE=WORK;CHARSET=UTF-8:SQA Road Creative PDE 00000'&$i&' Singapore'&@CRLF&'TEL;TYPE=WORK,VOICE:B 00000'&$i&@CRLF&'TEL;TYPE=HOME,VOICE:H 00000'&$i&@CRLF&'TEL;TYPE=WORK,FAX:BF 00000'&$i&@CRLF&'TEL;TYPE=CELL:M 00000'&$i&@CRLF&'EMAIL;TYPE=INTERNET:Contact'&$i&'@hotmail.com'&@CRLF&'TITLE;CHARSET=UTF-8:SQA'&$i&@CRLF&'ORG;CHARSET=UTF-8:Creative'&$i&';PDE'&$i&@CRLF&'URL;TYPE=HOME:www.contact'&$i&'.com'&@CRLF&'REV:20100208T173250Z'&@CRLF&'END:VCARD'&@CRLF&''
        FileWrite($p3&'\'&'Contacts.vcf', $Str)
        Next
EndFunc

Func Create4()
        $InputNum=GUICtrlRead($p)
        $p3=GUICtrlRead($p2)
        For $i=1 to $InputNum step 1
        $Str2 = 'BEGIN:VCARD'&@CRLF&'VERSION:3.0'&@CRLF&'UID:00000000DE68105447DED646B28E5393F7B7F46224C02000'&@CRLF&'FN;CHARSET=UTF-8:Contact000'&$i&@CRLF&'N;CHARSET=UTF-8:Contact000'&$i&';;;;'&@CRLF&'ADR;TYPE=WORK;CHARSET=UTF-8:;;SQA Road;Creative;PDE;00000000'&$i&';Singapore'&@CRLF&'LABEL;TYPE=WORK;CHARSET=UTF-8:SQA Road Creative PDE 00000000'&$i&' Singapore'&@CRLF&'TEL;TYPE=WORK,VOICE:B 00000000'&$i&@CRLF&'TEL;TYPE=HOME,VOICE:H 00000000'&$i&@CRLF&'TEL;TYPE=WORK,FAX:BF 00000000'&$i&@CRLF&'TEL;TYPE=CELL:M 00000000'&$i&@CRLF&'EMAIL;TYPE=INTERNET:Contact000'&$i&'@hotmail.com'&@CRLF&'TITLE;CHARSET=UTF-8:SQA000'&$i&@CRLF&'ORG;CHARSET=UTF-8:Creative000'&$i&';PDE000'&$i&@CRLF&'URL;TYPE=HOME:www.contact000'&$i&'.com'&@CRLF&'REV:20100208T173250Z'&@CRLF&'END:VCARD'&@CRLF&''
        FileWrite($p3&'\'&'Contacts.vcf', $Str)
        Next        
EndFunc        
那些 create() create2() create3() create4()里面可以忽略掉,单独的时候他们都是可以工作了,问题应该就在下拉选项和radio按键那边没有判断好,不知道应该怎样更改。谢谢大家。
发表于 2010-2-9 11:49:13 | 显示全部楼层
这是一个盛大网络的登录代码,你参考一下:
#include <IE.au3>
$url1 = "http://zh.sdo.com/web1.0/home/fastlogin.asp?CanScanArea=1010,1024&autoResize=false"
$oIE = _IECreate($url1, 0, 1, 1, 1)
$UserName = _IEGetObjById($oIE, "username")
If IsObj($UserName) Then $UserName.value = "xjlx0001"
$PassWord = _IEGetObjById($oIE, "password")
If IsObj($PassWord) Then $PassWord.value = "www110"
_IELinkClickByText($oIE, "登录")
    Sleep(3000)
$oForm = _IEFormGetObjByName ($oIE, "form1")
$oSelect = _IEFormElementGetObjByName ($oForm, "LoginServer")
For $i = 1 To 5
    _IEFormElementOptionSelect ($oSelect, "请选择区服)", 1, "byText")
        Sleep(1000)
        _IEFormElementOptionSelect ($oSelect, "铁血一区(电信区)", 1, "byText")
        Sleep(1000)
        _IEFormElementOptionSelect ($oSelect, 0, 1, "byIndex")
    Sleep(1000)
Next
发表于 2010-2-9 12:14:01 | 显示全部楼层
第42行  语法错误
 Switch $R=GUICtrlRead($Combo1)
改为:
$R=GUICtrlRead($Combo1)
 Switch $R
 楼主| 发表于 2010-2-9 14:26:13 | 显示全部楼层
回复 10# jhwl

谢谢!!!
果然是语法错误,修改了以后就可以正常工作了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-16 22:56 , Processed in 0.081572 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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