mshuking 发表于 2014-12-2 14:37:54

[已解决]au3 变量

本帖最后由 mshuking 于 2014-12-11 14:32 编辑

$Radio1 = GUICtrlCreateRadio("测试1", 16, 72, 91, 33, 0)
$Radio2 = GUICtrlCreateRadio("测试2", 128, 72, 99, 33, 0)
$Radio3 = GUICtrlCreateRadio("测试3", 248, 72, 99, 33, 0)
$Radio4 = GUICtrlCreateRadio("测试4", 368, 72, 99, 33, 0)
$Radio5 = GUICtrlCreateRadio("测试5", 488, 72, 99, 33, 0)
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
$Radio48 = GUICtrlCreateRadio("测试48", 848, 304, 91, 33, 0)
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
$Button1 = GUICtrlCreateButton("测试", 816, 728, 131, 73, 0)
$Radio = $Radio1.。。。。。。。。。。。$Radio48               注 :这里怎么写
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
        Case $Button1
                     If GUICtrlRead(这时调用$Radio才好使) = $GUI_CHECKED Then run("", "", @sw_hide)$Radio = $Radio1.。。。。。。。。。。。$Radio48               注 :这里怎么写
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
        Case $Button1
                     If GUICtrlRead(这时调用$Radio才好使) = $GUI_CHECKED Then run("", "", @sw_hide)

mshuking 发表于 2014-12-2 14:40:27

Case $Button1
                     If GUICtrlRead($Radio1) = $GUI_CHECKED Then run("", "", @sw_hide)
                     If GUICtrlRead($Radio2) = $GUI_CHECKED Then run("", "", @sw_hide)
                     。
                     If GUICtrlRead($Radio48) = $GUI_CHECKED Then run("", "", @sw_hide)
这样要写好长


         $Radio = $Radio1.。。。。。。。。。。。$Radio48
      Case $Button1
                  If GUICtrlRead($Radio) = $GUI_CHECKED Then run("", "", @sw_hide)

laomeng 发表于 2014-12-2 17:07:25

如果运行的东西不一样 只能 一个一个的写吧

user3000 发表于 2014-12-2 17:57:37

回复 1# mshuking


用数组存放要运行的命令,就可以大大的简化代码.Local $radio = 0
Local $exec = ['c:\1.exe', 'd:\2.exe'] ;........
;....
$Radio1 = GUICtrlCreateRadio("测试1", 16, 72, 91, 33, 0)
GUICtrlSetState(-1, $gui_checked)
$Radio2 = GUICtrlCreateRadio("测试2", 128, 72, 99, 33, 0)
;.....
$Radio48 = GUICtrlCreateRadio("测试48", 848, 304, 91, 33, 0)
; .....
$Button1 = GUICtrlCreateButton("测试", 816, 728, 131, 73, 0)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg               
                Case $radio1 To $radio48
                     $radio = $nMsg - $radio1
                           ; 点击 $Radio1 $radio = 0<<==>> $exec
                           ; 点击 $Radio2 $radio = 1<<==>> $exec
                           ;...
                           ; 点击 $Radio48 $radio = 47 <<==>> $exec
                Case $button1
                           Run($exec[$radio], '', @SW_HIDE)
    EndSwitch
WEnd

nqawen 发表于 2014-12-3 18:50:52

学习了,数组法不错

mshuking 发表于 2014-12-4 13:17:15

谢谢。。。。。。。

mshuking 发表于 2014-12-4 13:17:30

Case $radio1 To $radio48

                     $radio = $nMsg - $radio1

                           ; 点击 $Radio1 $radio = 0<<==>> $exec

                           ; 点击 $Radio2 $radio = 1<<==>> $exec

                           ;...

                           ; 点击 $Radio48 $radio = 47 <<==>> $exec

                Case $button1

                           Run($exec[$radio], '', @SW_HIDE)

wangms 发表于 2014-12-5 08:38:07

前来学习。。。。。。。。。。。。。。

樱花雪月 发表于 2014-12-5 11:41:56

路过学习看看
页: [1]
查看完整版本: [已解决]au3 变量