找回密码
 加入
搜索
查看: 1221|回复: 7

帮忙看下这个变量该怎么写???

[复制链接]
发表于 2009-9-1 22:24:52 | 显示全部楼层 |阅读模式
本帖最后由 zjg2003 于 2009-9-5 18:57 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("太阳网在线电影", 292, 175)
$Button1 = GUICtrlCreateButton("Button1", 16, 16, 73, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 109, 16, 73, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 202, 16, 73, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Button4", 16, 61, 73, 25, $WS_GROUP)
$Button5 = GUICtrlCreateButton("Button5", 109, 61, 73, 25, $WS_GROUP)
$Button6 = GUICtrlCreateButton("Button6", 202, 61, 73, 25, $WS_GROUP)
$Button7 = GUICtrlCreateButton("Button7", 16, 106, 73, 25, $WS_GROUP)
$Button8 = GUICtrlCreateButton("Button8", 109, 106, 73, 25, $WS_GROUP)
$Button9 = GUICtrlCreateButton("Button9", 202, 106, 73, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("如果大家有比较好的免费电影请推荐给网管添加", 19, 148, 256, 17)


For $i = 1 To 9
        $var = IniRead( "在线电影.ini", "按钮名称","按钮"& $i,"")
        GUICtrlSetData( "$Button" & $i,$var)
Next

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
红色的GUICtrlSetData( "$Button" & $i,$var)执行后相当于代码GUICtrlSetData( "$Button1" ,$var)  注:这里 假设$i为1时   这样并没有效果。

正确的应该是执行GUICtrlSetData( $Button1 ,$var) 才能生效。上面的多了一对引号,正确应该没引号的,要怎么处理???

谢谢
 楼主| 发表于 2009-9-1 22:28:00 | 显示全部楼层
本帖最后由 zjg2003 于 2009-9-2 11:44 编辑

1楼的问题解决了,现在又有了新问题,就是点击按钮打开相应的网站:
例如点按钮一就打开百度,点按钮2就打开163,共有九个(指定为Opt("GUIOnEventMode",1)模式)

For $i = 1 To 9
        $var = IniRead( "在线电影.ini", "按钮名称","按钮"& $i,"")
        GUICtrlSetData(Eval("Button" & $i),$var)
      GUICtrlSetOnEvent(Eval("Button" & $i), "_Button") ;这里指定按钮事件
Next
Func _Button()  
        For $i = 1 To 9
        $var = IniRead( "在线电影.ini", "按钮链接","按钮"& $i,"")
                ShellExecute ( @ProgramFilesDir & "\Internet Explorer\IEXPLORE.exe" ,$var )
        Next
EndFunc
;这函数要怎么去判断是点击了哪个按钮呢???各位前辈请帮忙


下面是INI文件内容:

[按钮名称]
按钮1=吉安影院
按钮2=土豆影院

[按钮链接]
按钮1=www.baidu.com
按钮2=www.163.com
发表于 2009-9-1 22:33:25 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("太阳网在线电影", 292, 175)
$Button1 = GUICtrlCreateButton("Button1", 16, 16, 73, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 109, 16, 73, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 202, 16, 73, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Button4", 16, 61, 73, 25, $WS_GROUP)
$Button5 = GUICtrlCreateButton("Button5", 109, 61, 73, 25, $WS_GROUP)
$Button6 = GUICtrlCreateButton("Button6", 202, 61, 73, 25, $WS_GROUP)
$Button7 = GUICtrlCreateButton("Button7", 16, 106, 73, 25, $WS_GROUP)
$Button8 = GUICtrlCreateButton("Button8", 109, 106, 73, 25, $WS_GROUP)
$Button9 = GUICtrlCreateButton("Button9", 202, 106, 73, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("如果大家有比较好的免费电影请推荐给网管添加", 19, 148, 256, 17)


For $i = 1 To 9
        $var = IniRead( "在线电影.ini", "按钮名称","按钮"& $i,"")
        GUICtrlSetData(Eval("Button" & $i),$var)
Next

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
发表于 2009-9-1 22:35:06 | 显示全部楼层
本帖最后由 netegg 于 2009-9-1 22:42 编辑

for $i = 1 to 9
guisetdata($Button & $i,  "数值" & $i)
next
记得好像可以这样,而且好像中间还要转换下变量
建议你做按键的时候用数组,方便些
发表于 2009-9-2 00:41:14 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("太阳网在线电影", 292, 175)
Dim $Button[10]=[9]
$Button[1] = GUICtrlCreateButton("Button1", 16, 16, 73, 25, $WS_GROUP)
$Button[2] = GUICtrlCreateButton("Button2", 109, 16, 73, 25, $WS_GROUP)
$Button[3] = GUICtrlCreateButton("Button3", 202, 16, 73, 25, $WS_GROUP)
$Button[4] = GUICtrlCreateButton("Button4", 16, 61, 73, 25, $WS_GROUP)
$Button[5] = GUICtrlCreateButton("Button5", 109, 61, 73, 25, $WS_GROUP)
$Button[6] = GUICtrlCreateButton("Button6", 202, 61, 73, 25, $WS_GROUP)
$Button[7] = GUICtrlCreateButton("Button7", 16, 106, 73, 25, $WS_GROUP)
$Button[8] = GUICtrlCreateButton("Button8", 109, 106, 73, 25, $WS_GROUP)
$Button[9] = GUICtrlCreateButton("Button9", 202, 106, 73, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("如果大家有比较好的免费电影请推荐给网管添加", 19, 148, 256, 17)


For $i = 1 To 9
        $var = IniRead( "在线电影.ini", "按钮名称","按钮"& $i,"")
        GUICtrlSetData($Button[$i],$var)
Next

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
这是用数组的.
发表于 2009-9-2 02:31:55 | 显示全部楼层
5# bing614

Dim $Button[10]=[9]
这行是什么意思
发表于 2009-9-2 03:48:13 | 显示全部楼层
给0号数组 一个9   我估计是为了计数吧  0号一般放count
 楼主| 发表于 2009-9-2 11:45:41 | 显示全部楼层
先谢谢楼上各位帮忙的兄弟
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-28 20:33 , Processed in 0.077837 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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