找回密码
 加入
搜索
查看: 1273|回复: 5

Switch相关问题

[复制链接]
发表于 2010-1-25 23:03:42 | 显示全部楼层 |阅读模式
本帖最后由 xlcwxl 于 2010-1-26 00:34 编辑
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 183, 92, -1,-1)
$Combo1 = GUICtrlCreateCombo("", 16, 8, 145, 25)
GUICtrlSetData(-1,'1|2|3',1)
$Button1 = GUICtrlCreateButton("Button1", 88, 40, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
Switch GUICtrlRead($Combo1)
Case "1"
$xz = '1.bat'
Case "2"
$xz = '2.bat'
Case "3"
$xz = '3.bat'
EndSwitch
Case $Button1
MsgBox(64,'',$xz)        
EndSwitch
WEnd
为何必须选择一次才能读取数据,默认数据的话一闪而过,为什么?

答案4#

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-1-25 23:59:27 | 显示全部楼层
本帖最后由 catcher 于 2010-1-26 00:09 编辑

先给变量设置一个初值

Dim $xz= "1.bat"
$Form1 = GUICreate("Form1", 183, 92, -1,-1)
................


等高手来解答
发表于 2010-1-26 00:13:31 | 显示全部楼层
不明白楼主说什么。,
发表于 2010-1-26 00:15:33 | 显示全部楼层

不明白楼主为什么要搞复杂化?另外如楼上所说赋值,也可方法2,也可其他,多的是

$Form1 = GUICreate("Form1", 183, 92, -1,-1)
$Combo1 = GUICtrlCreateCombo("", 16, 8, 145, 25)
GUICtrlSetData(-1,'1|2|3',1)
$Button1 = GUICtrlCreateButton("Button1", 88, 40, 75, 25)
GUISetState(@SW_SHOW)

While 1
 $nMsg = GUIGetMsg()
  Switch $nMsg
   Case -3
    Exit
   Case $Button1
    MsgBox(64,'',GUICtrlRead($Combo1)&'.bat')        
  EndSwitch
WEnd
2
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 183, 92, -1,-1)
$Combo1 = GUICtrlCreateCombo("", 16, 8, 145, 25)
GUICtrlSetData(-1,'1|2|3',1)
GUICtrlSetState(-1,$GUI_FOCUS)
$Button1 = GUICtrlCreateButton("Button1", 88, 40, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Send('{down}')
Send('{up}')

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
Switch GUICtrlRead($Combo1)
Case "1"
$xz = '1.bat'
Case "2"
$xz = '2.bat'
Case "3"
$xz = '3.bat'
EndSwitch
Case $Button1
MsgBox(64,'',$xz)        
EndSwitch
WEnd
 楼主| 发表于 2010-1-26 00:24:59 | 显示全部楼层
回复 4# kn007
谢谢啦
这两种办法我知道,我是想问有更好的办法没
发表于 2010-1-26 07:47:23 | 显示全部楼层
变量 $xz 需要先声明
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 02:15 , Processed in 0.123215 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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