找回密码
 加入
搜索
查看: 2099|回复: 4

[已解决]While 1……WEnd相关问题

[复制链接]
发表于 2009-4-17 13:43:47 | 显示全部楼层 |阅读模式
用Koda编缉器做了一个GUI,在While 1……WEnd之间加入按钮取值后,未点击相关按钮,程序运行时就自动弹出来了!请指点下,全代码如下:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <process.au3>
;#NoTrayIcon

FileInstall("公告内容.txt", @ScriptDir & "\公告内容.txt", 0)
FileInstall("配置.ini", @ScriptDir & "\配置.ini", 0)
$File = @ScriptDir&"\配置.ini"
$gglr = @ScriptDir&"\公告内容.txt"
$infcheck = FileExists(@ScriptDir & "\配置.ini");检查指定文件或目录是否存在

;=====================读取按钮相关配置================
Dim $Button[65]
;======读取按钮
$Button[1]=IniRead($File,"Web","web1","")
$Button[2]=IniRead($File,"Web","web2","")
$Button[3]=IniRead($File,"Web","web3","")
$Button[4]=IniRead($File,"Web","web4","")
;======读取按钮地址 $为上面所得到的
$Button[5]=IniRead($File,"Web",$Button[1],"")
$Button[6]=IniRead($File,"Web",$Button[2],"")
$Button[7]=IniRead($File,"Web",$Button[3],"")
$Button[8]=IniRead($File,"Web",$Button[4],"")

;=======读取TV按钮
$Button[9]=IniRead($File,"TV","TV1","")
$Button[10]=IniRead($File,"TV","TV2","")
$Button[11]=IniRead($File,"TV","TV3","")
$Button[12]=IniRead($File,"TV","TV4","")
$Button[13]=IniRead($File,"TV","TV5","")
$Button[14]=IniRead($File,"TV","TV6","")
$Button[15]=IniRead($File,"TV","TV7","")
$Button[16]=IniRead($File,"TV","TV8","")
$Button[17]=IniRead($File,"TV","TV9","")
$Button[18]=IniRead($File,"TV","TV10","")
$Button[19]=IniRead($File,"TV","TV11","")
$Button[20]=IniRead($File,"TV","TV12","")
$Button[21]=IniRead($File,"TV","TV13","")
$Button[22]=IniRead($File,"TV","TV14","")
$Button[23]=IniRead($File,"TV","TV15","")
$Button[24]=IniRead($File,"TV","TV16","")
$Button[25]=IniRead($File,"TV","TV17","")
$Button[26]=IniRead($File,"TV","TV18","")
$Button[27]=IniRead($File,"TV","TV19","")
$Button[28]=IniRead($File,"TV","TV20","")
$Button[29]=IniRead($File,"TV","TV21","")
$Button[30]=IniRead($File,"TV","TV22","")
$Button[31]=IniRead($File,"TV","TV23","")
$Button[32]=IniRead($File,"TV","TV24","")
$Button[33]=IniRead($File,"TV","TV25","")
$Button[34]=IniRead($File,"TV","TV26","")
$Button[35]=IniRead($File,"TV","TV27","")
$Button[36]=IniRead($File,"TV","TV28","")
;;========读取TV按钮值
$Button[37]=IniRead($File,"TV",$Button[9],"")
$Button[38]=IniRead($File,"TV",$Button[10],"")
$Button[39]=IniRead($File,"TV",$Button[11],"")
$Button[40]=IniRead($File,"TV",$Button[12],"")
$Button[41]=IniRead($File,"TV",$Button[13],"")
$Button[42]=IniRead($File,"TV",$Button[14],"")
$Button[43]=IniRead($File,"TV",$Button[15],"")
$Button[44]=IniRead($File,"TV",$Button[16],"")
$Button[45]=IniRead($File,"TV",$Button[17],"")
$Button[46]=IniRead($File,"TV",$Button[18],"")
$Button[47]=IniRead($File,"TV",$Button[19],"")
$Button[48]=IniRead($File,"TV",$Button[20],"")
$Button[49]=IniRead($File,"TV",$Button[21],"")
$Button[50]=IniRead($File,"TV",$Button[22],"")
$Button[51]=IniRead($File,"TV",$Button[23],"")
$Button[52]=IniRead($File,"TV",$Button[24],"")
$Button[53]=IniRead($File,"TV",$Button[25],"")
$Button[54]=IniRead($File,"TV",$Button[26],"")
$Button[55]=IniRead($File,"TV",$Button[27],"")
$Button[56]=IniRead($File,"TV",$Button[28],"")
$Button[57]=IniRead($File,"TV",$Button[29],"")
$Button[58]=IniRead($File,"TV",$Button[30],"")
$Button[59]=IniRead($File,"TV",$Button[31],"")
$Button[60]=IniRead($File,"TV",$Button[32],"")
$Button[61]=IniRead($File,"TV",$Button[33],"")
$Button[62]=IniRead($File,"TV",$Button[34],"")
$Button[63]=IniRead($File,"TV",$Button[35],"")
$Button[64]=IniRead($File,"TV",$Button[36],"")
;=====================读取按钮配置结束================

#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\form1.kxf
$Form1 = GUICreate("影视工具", 516, 408, 215, 111)
GUISetBkColor(0x808000)
$Group1 = GUICtrlCreateGroup("在线影院", 0, 8, 513, 57)
$Button1 = GUICtrlCreateButton($Button[1], 8, 24, 89, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 12, 800, 0, "楷体_GB2312")
GUICtrlSetBkColor(-1, 0x008000)
$Button2 = GUICtrlCreateButton($Button[2], 144, 24, 89, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 12, 800, 0, "楷体_GB2312")
GUICtrlSetBkColor(-1, 0x008000)
$Button3 = GUICtrlCreateButton($Button[3], 280, 24, 89, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 12, 800, 0, "楷体_GB2312")
GUICtrlSetBkColor(-1, 0x008000)
$Button4 = GUICtrlCreateButton($Button[4], 416, 24, 89, 33, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 12, 800, 0, "楷体_GB2312")
GUICtrlSetBkColor(-1, 0x008000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("电视直播", 0, 64, 513, 177)
$Button5 = GUICtrlCreateButton($Button[9], 8, 80, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button6 = GUICtrlCreateButton($Button[10], 80, 80, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button7 = GUICtrlCreateButton($Button[11], 152, 80, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button8 = GUICtrlCreateButton($Button[12], 224, 80, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button9 = GUICtrlCreateButton($Button[13], 296, 80, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button10 = GUICtrlCreateButton($Button[14], 368, 80, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button11 = GUICtrlCreateButton($Button[15], 440, 80, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button12 = GUICtrlCreateButton($Button[16], 8, 120, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button13 = GUICtrlCreateButton($Button[17], 80, 120, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button14 = GUICtrlCreateButton($Button[18], 152, 120, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button15 = GUICtrlCreateButton($Button[19], 224, 120, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button16 = GUICtrlCreateButton($Button[20], 296, 120, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button17 = GUICtrlCreateButton($Button[21], 368, 120, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button18 = GUICtrlCreateButton($Button[22], 440, 120, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button19 = GUICtrlCreateButton($Button[23], 8, 160, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button20 = GUICtrlCreateButton($Button[24], 80, 160, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button21 = GUICtrlCreateButton($Button[25], 152, 160, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button22 = GUICtrlCreateButton($Button[26], 224, 160, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button23 = GUICtrlCreateButton($Button[27], 296, 160, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button24 = GUICtrlCreateButton($Button[28], 368, 160, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button25 = GUICtrlCreateButton($Button[29], 440, 160, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button26 = GUICtrlCreateButton($Button[30], 8, 200, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button27 = GUICtrlCreateButton($Button[31], 80, 200, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button28 = GUICtrlCreateButton($Button[32], 152, 200, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button29 = GUICtrlCreateButton($Button[33], 224, 200, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button30 = GUICtrlCreateButton($Button[34], 296, 200, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button31 = GUICtrlCreateButton($Button[35], 368, 200, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
$Button32 = GUICtrlCreateButton($Button[36], 440, 200, 65, 33, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x008000)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Read = FileRead($gglr,FileGetSize($gglr));从此前已打开的文本文件中读取指定数量的字符
$ggbt =IniRead($File, "公告板样式", "公告板标题", "")
$RGB = IniRead($File, "公告板样式", "字体颜色", "")
$Font = IniRead($File, "公告板样式", "字体大小", "")
$Font_1 = IniRead($File, "公告板样式", "使用字体", "")
$Group3 = GUICtrlCreateGroup($ggbt, 0, 240, 513, 161)
$Edit1 = GUICtrlCreateEdit("", 8, 256, 497, 137, $ES_READONLY, 0)
GUICtrlSetData(-1, StringFormat($Read));修改指定控件的相关数据
GUICtrlSetFont(-1, $Font, 0, 0, $Font_1);字体大小,字体样式
GUICtrlSetColor(-1, $RGB);字体颜色
;GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        
$nMsg = GUIGetMsg()
        Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                        case $Button[9] 
                                MsgBox(0,"测试","测试成功",5)
                                
        EndSwitch
                
WEnd

配置.ini
如下
[版权信息]
飞翔浪子=QQ:472891322
E-mail=jycel@qq.com
作者空间=http://472891322.qzone.qq.com/
公司地址=西南科技大学飛翔網絡城
;本软件可自由传播,但请保留作者版权,请勿修改以上信息!

[公告板样式]
公告板标题=网吧公告
字体颜色=0x008000
字体大小=9
使用字体=宋体

[Web]
Web1=天府宽频
Web2=专线影院
Web3=网吧论坛
Web4=互动网盟
;以上为按钮名称,修改后请连同以下名称同时修改,或者造成错误!

天府宽频=http://v.tfol.com/netbar.aspx
专线影院=http://20.20.2.102/webmedia/html/index.shtml
网吧论坛=http://192.168.0.254/ly
互动网盟=http://www.fxwlc2624067.51hdwm.com

[TV]
TV1=重庆卫视
TV2=峨嵋电影
TV3=湖南卫视
TV4=安徽卫视
TV5=浙江卫视
TV6=科教频道
TV7=江苏卫视

TV8=CCTV-1套
TV9=CCTV-3套
TV10=CCTV-5套
TV11=CCTV-6套
TV12=CCTV10套
TV13=CCTV12套
TV14=中国教育

TV15=成都-1套
TV16=成都-3套
TV17=成都-4套
TV18=四川-3套
TV19=四川-4套
TV20=四川-5套
TV21=四川-6套

TV22=北京卫视
TV23=上海卫视
TV24=江西卫视
TV25=深圳卫视
TV26=山东卫视
TV27=广东卫视
TV28=陕西卫视

;以上为按钮名称,修改后请连同以下名称同时修改,或者造成错误!
重庆卫视=mms://20.20.2.100/121
陕西卫视=mms://20.20.2.100/101
峨嵋电影=mms://20.20.2.100/124
湖南卫视=mms://20.20.2.100/128
CCTV-1套=mms://20.20.2.100/114
CCTV-3套=mms://20.20.2.100/105
CCTV-5套=mms://20.20.2.100/125

CCTV-6套=mms://20.20.2.100/108
CCTV10套=mms://20.20.2.100/123
CCTV12套=mms://20.20.2.100/110
中国教育=mms://20.20.2.100/104
成都-1套=mms://20.20.2.100/103
成都-3套=mms://20.20.2.100/131
成都-4套=mms://20.20.2.100/115

科教频道=mms://20.20.2.100/122
四川-3套=mms://20.20.2.100/106
四川-4套=mms://20.20.2.100/109
四川-5套=mms://20.20.2.100/107
四川-6套=mms://20.20.2.100/102
上海卫视=mms://20.20.2.100/113
江西卫视=mms://20.20.2.100/117

江苏卫视=mms://20.20.2.100/118
深圳卫视=mms://20.20.2.100/119
浙江卫视=mms://20.20.2.100/112
山东卫视=mms://20.20.2.100/126
安徽卫视=mms://20.20.2.100/116
广东卫视=mms://20.20.2.100/120
北京卫视=mms://20.20.2.100/111

[ 本帖最后由 jycel 于 2009-4-18 18:04 编辑 ]
发表于 2009-4-17 13:52:05 | 显示全部楼层
$nMsg = GUIGetMsg()
        Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                        case $Button9
                                MsgBox(0,"测试","测试成功",5)
                               
        EndSwitch
               
WEnd
 楼主| 发表于 2009-4-17 13:56:34 | 显示全部楼层
一样的啊,你只是把$Button[9]换成了$Button9  还是老样,运行程序就自动弹
我试了不管是用数组还是非数组都一样!奇怪了!是不是还差什么语句,我对照了下其它的都一样的!

[ 本帖最后由 jycel 于 2009-4-17 13:58 编辑 ]
发表于 2009-4-17 14:17:48 | 显示全部楼层
原帖由 顽固不化 于 2009-4-17 13:52 发表
$nMsg = GUIGetMsg()
        Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                        case $Button9
                                MsgBox(0,"测试","测试成功",5)
                               
        EndSwitch
               
WEnd

case $Button9
 楼主| 发表于 2009-4-17 14:42:36 | 显示全部楼层
找到原因了!原来$Button[9] 的值是读取配置文件中的按钮名去了,正确定该为
case $Button5难怪运行就弹出来!
全部重新改才发现!小小错误搞半天
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-23 22:57 , Processed in 0.075314 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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