帮忙看下这个变量该怎么写???
本帖最后由 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) 才能生效。上面的多了一对引号,正确应该没引号的,要怎么处理???
谢谢 本帖最后由 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") ;这里指定按钮事件
NextFunc _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 #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 本帖最后由 netegg 于 2009-9-1 22:42 编辑
for $i = 1 to 9
guisetdata($Button & $i,"数值" & $i)
next
记得好像可以这样,而且好像中间还要转换下变量
建议你做按键的时候用数组,方便些 #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("太阳网在线电影", 292, 175)
Dim $Button=
$Button = GUICtrlCreateButton("Button1", 16, 16, 73, 25, $WS_GROUP)
$Button = GUICtrlCreateButton("Button2", 109, 16, 73, 25, $WS_GROUP)
$Button = GUICtrlCreateButton("Button3", 202, 16, 73, 25, $WS_GROUP)
$Button = GUICtrlCreateButton("Button4", 16, 61, 73, 25, $WS_GROUP)
$Button = GUICtrlCreateButton("Button5", 109, 61, 73, 25, $WS_GROUP)
$Button = GUICtrlCreateButton("Button6", 202, 61, 73, 25, $WS_GROUP)
$Button = GUICtrlCreateButton("Button7", 16, 106, 73, 25, $WS_GROUP)
$Button = GUICtrlCreateButton("Button8", 109, 106, 73, 25, $WS_GROUP)
$Button = 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这是用数组的. 5# bing614
Dim $Button=
这行是什么意思 给0号数组 一个9 我估计是为了计数吧0号一般放count 先谢谢楼上各位帮忙的兄弟
页:
[1]