找回密码
 加入
搜索
查看: 5538|回复: 14

[GUI管理] [已解决]按1次down 紅色往下跑, 再按1次再往下跑

  [复制链接]
发表于 2010-8-11 23:33:18 | 显示全部楼层 |阅读模式
本帖最后由 tcpuuu 于 2010-8-13 00:09 编辑


按1次down 紅色往下跑, 再按1次再往下跑
按up 往上跑  這要怎麼 編ㄚ?

求助好心人教教我   我的e-mail :  hh.tr@msa.hinet.net
----------------------------------------------------
#include <GUIConstants.au3>
GUICreate(" Win ", 110, 302,800,2) ; 建窗口
GUICtrlCreateLabel ("1",2,2,62,36,$WS_BORDER)
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetFont (-1,24 );GUICtrlSetStyle (-1, $SS_RIGHT )

GUICtrlCreateLabel ("2",2,40,62,36,$WS_BORDER)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetFont (-1,24 );GUICtrlSetStyle (-1, $SS_RIGHT )

GUICtrlCreateLabel ("3",2,78,62,36,$WS_BORDER)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetFont (-1,24 );GUICtrlSetStyle (-1, $SS_RIGHT )


$1Button = GUICtrlCreateButton("down", 65, 1, 40,30);建按鈕控件
$2Button = GUICtrlCreateButton("up", 65, 31, 40,30);建按鈕控件
GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg()

Select
Case $msg = $1button

Case $msg = $2button

Case $msg = $GUI_EVENT_CLOSE   
ExitLoop
EndSelect
WEnd

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

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

查看全部评分

发表于 2010-8-11 23:57:45 | 显示全部楼层
GUICreate(" Win ", 110, 302, 800, 2)

$L1 = GUICtrlCreateLabel("1", 2, 2, 62, 36, 0x00800000) ;$WS_BORDER = 0x00800000
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetFont(-1, 24)

$L2 = GUICtrlCreateLabel("2", 2, 40, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$L3 = GUICtrlCreateLabel("3", 2, 78, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$1Button = GUICtrlCreateButton("down", 65, 1, 40, 30)
$2Button = GUICtrlCreateButton("up", 65, 31, 40, 30)
$3Button = GUICtrlCreateButton("Cycle", 65, 62, 40, 30)
GUISetState()

$bj = $L1
While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case -3
                        Exit
                Case $1Button
                        If $bj = $L3 Then ContinueLoop
                        GUICtrlSetBkColor($bj, 0xFFFFFF)
                        $bj += 1
                        GUICtrlSetBkColor($bj, 0xFF0000)
                Case $2Button
                        If $bj = $L1 Then ContinueLoop
                        GUICtrlSetBkColor($bj, 0xFFFFFF)
                        $bj -= 1
                        GUICtrlSetBkColor($bj, 0xFF0000)
                Case $3Button
                        GUICtrlSetBkColor($bj, 0xFFFFFF)
                        $bj += 1
                        If $bj = $L3 + 1 Then $bj = $L1
                        GUICtrlSetBkColor($bj, 0xFF0000)
        EndSwitch
WEnd
发表于 2010-8-11 23:59:24 | 显示全部楼层
順便在上面加上了循環按鈕
发表于 2010-8-12 00:24:14 | 显示全部楼层
我也来一个
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

GUICreate(" Win ", 110, 302,800,2) ; 建窗口
$Label1 = GUICtrlCreateLabel ("1",2,2,62,36,$WS_BORDER)
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetFont (-1,24 );GUICtrlSetStyle (-1, $SS_RIGHT )

$Label2 = GUICtrlCreateLabel ("2",2,40,62,36,$WS_BORDER)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetFont (-1,24 );GUICtrlSetStyle (-1, $SS_RIGHT )

$Label3 = GUICtrlCreateLabel ("3",2,78,62,36,$WS_BORDER)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetFont (-1,24 );GUICtrlSetStyle (-1, $SS_RIGHT )

$1Button = GUICtrlCreateButton("down", 65, 1, 40,30);建按鈕控件
$2Button = GUICtrlCreateButton("up", 65, 31, 40,30);建按鈕控件
GUISetState(@SW_SHOW)

Global $s = 1
While 1
  $msg = GUIGetMsg()
Switch $msg
        Case $1Button
                GUICtrlSetBkColor(Eval("Label"&$s),0xFFFFFF)
                $s += 1
                If $s = 4 Then $s = 1
           GUICtrlSetBkColor(Eval("Label"&$s),0xFF0000)
    Case $2Button
       GUICtrlSetBkColor(Eval("Label"&$s),0xFFFFFF)
                $s -= 1
                If $s = 0 Then $s = 3
           GUICtrlSetBkColor(Eval("Label"&$s),0xFF0000)
    Case $GUI_EVENT_CLOSE    
       ExitLoop
EndSwitch
WEnd

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-8-12 01:03:34 | 显示全部楼层
謝謝你們! 你們好厲害ㄛ!
我 台灣人 好笨!
 楼主| 发表于 2010-8-12 01:50:24 | 显示全部楼层
再請教你們一下
如果跑到2   除了紅色往下移   再 執行  222.exe
Run("c:\222.exe")

跑到3  紅色往下移  再執行  333.exe
Run("c:\333.exe")
------------------------------------------------------------
這要如何寫...?

謝謝你們!
发表于 2010-8-12 02:06:09 | 显示全部楼层
GUICreate(" Win ", 110, 302, 800, 2)

$L1 = GUICtrlCreateLabel("1", 2, 2, 62, 36, 0x00800000) ;$WS_BORDER = 0x00800000
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetFont(-1, 24)

$L2 = GUICtrlCreateLabel("2", 2, 40, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$L3 = GUICtrlCreateLabel("3", 2, 78, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$1Button = GUICtrlCreateButton("down", 65, 1, 40, 30)
$2Button = GUICtrlCreateButton("up", 65, 31, 40, 30)
$3Button = GUICtrlCreateButton("Cycle", 65, 62, 40, 30)
GUISetState()

Dim $bj = $L1
Dim $exe[3] = ['程式1(aaa).exe', '程式2(bbb).exe', '程式3(ccc).exe']
While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case -3
                        Exit
                Case $1Button
                        If $bj = $L3 Then ContinueLoop
                        GUICtrlSetBkColor($bj, 0xFFFFFF)
                        $bj += 1
                        GUICtrlSetBkColor($bj, 0xFF0000)
                        msgbox(0, 0, $exe[$bj - 3], 1)
                Case $2Button
                        If $bj = $L1 Then ContinueLoop
                        GUICtrlSetBkColor($bj, 0xFFFFFF)
                        $bj -= 1
                        GUICtrlSetBkColor($bj, 0xFF0000)
                        msgbox(0, 0, $exe[$bj - 3], 1)
                Case $3Button
                        GUICtrlSetBkColor($bj, 0xFFFFFF)
                        $bj += 1
                        If $bj = $L3 + 1 Then $bj = $L1
                        GUICtrlSetBkColor($bj, 0xFF0000)
                        msgbox(0, 0, $exe[$bj - 3], 1)
        EndSwitch
WEnd
具體應用將 msgbox(0, 0, $exe[$bj - 3], 1) 替換成 Run($exe[$bj - 3]) 即可
发表于 2010-8-12 02:17:31 | 显示全部楼层
本帖最后由 afan 于 2010-8-12 02:19 编辑

精簡下
GUICreate(" Win ", 110, 302, 800, 2)

$L1 = GUICtrlCreateLabel("1", 2, 2, 62, 36, 0x00800000) ;$WS_BORDER = 0x00800000
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetFont(-1, 24)

$L2 = GUICtrlCreateLabel("2", 2, 40, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$L3 = GUICtrlCreateLabel("3", 2, 78, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$1Button = GUICtrlCreateButton("down", 65, 1, 40, 30)
$2Button = GUICtrlCreateButton("up", 65, 31, 40, 30)
$3Button = GUICtrlCreateButton("Cycle", 65, 62, 40, 30)
GUISetState()

Dim $bj = $L1
Dim $exe[3] = ['C:\程式1(aaa).exe', 'C:\程式2(bbb).exe', 'C:\程式3(ccc).exe']
While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case -3
                        Exit
                Case $1Button To $3Button
                        Go($msg)
        EndSwitch
WEnd

Func Go($msg)
        If ($msg = $1Button And $bj = $L3) Or ($msg = $2Button And $bj = $L1) Then Return
        GUICtrlSetBkColor($bj, 0xFFFFFF)
        $bj += 1
        If $msg = $2Button Then $bj -= 2
        If $msg = $3Button And $bj = $L3 + 1 Then $bj = $L1
        GUICtrlSetBkColor($bj, 0xFF0000)
        MsgBox(0, 0, $exe[$bj - 3], 1)
EndFunc   ;==>Go

评分

参与人数 1金钱 +30 收起 理由
C.L + 30 我很赞同

查看全部评分

发表于 2010-8-12 12:31:37 | 显示全部楼层
A1, 8#代码 第4行與第8行調換,第20改為 Dim $bj = $L2 即可。
A2, “按下去 原地不動”不太懂意思…
发表于 2010-8-12 14:44:53 | 显示全部楼层
楼主能不能把问题一次问明白,一点点挤牙膏似的,太不适合设计代码了
 楼主| 发表于 2010-8-12 18:59:33 | 显示全部楼层
謝謝!  板主 解說   ....不好意思   打擾了
“按下去 原地不動”不太懂意思…
----------------------------------------------
按DOWN 跑到2  執行'C:\程式2(bbb).exe'   
如果按 第三鍵3Button(原地不動,不上也不下) 停在2  再執行'C:\程式2(bbb).exe'   一次
发表于 2010-8-12 19:02:43 | 显示全部楼层
那第三鍵只起到重複執行的作用,并不做循環之用,是這意思嗎?
 楼主| 发表于 2010-8-12 22:03:34 | 显示全部楼层
本帖最后由 tcpuuu 于 2010-8-12 22:23 编辑

對的! 第3鍵不做循環  
----------------------------------
如果 按1或2 鍵, 紅色跑到3 執行3.EXE
這時按第3鍵  紅色停在原地3 再執行 3.EXE  一次

如果 按1或2 鍵, 紅色跑到2 執行2.EXE
這時按第3鍵  紅色停在原地2 再執行 2.EXE  一次
----------------------------------------------------------
第3鍵 讓 紅色不移動 (停在原地再執行原地的 XXX.exe 一次)   

---再次感謝 板主afan ---
发表于 2010-8-12 23:14:29 | 显示全部楼层
GUICreate(" Win ", 110, 302, 800, 2)

$L1 = GUICtrlCreateLabel("1", 2, 2, 62, 36, 0x00800000) ;$WS_BORDER = 0x00800000
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$L2 = GUICtrlCreateLabel("2", 2, 40, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetFont(-1, 24)

$L3 = GUICtrlCreateLabel("3", 2, 78, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$1Button = GUICtrlCreateButton("down", 65, 1, 40, 30)
$2Button = GUICtrlCreateButton("up", 65, 31, 40, 30)
$3Button = GUICtrlCreateButton("Cycle", 65, 62, 40, 30)
GUISetState()

Dim $bj = $L2
Dim $exe[3] = ['C:\程式1(aaa).exe', 'C:\程式2(bbb).exe', 'C:\程式3(ccc).exe']
While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case -3
                        Exit
                Case $1Button To $2Button
                        Go($msg)
                Case $3Button
                        MsgBox(0, 0, $exe[$bj - 3], 1)
        EndSwitch
WEnd

Func Go($msg)
        If ($msg = $1Button And $bj = $L3) Or ($msg = $2Button And $bj = $L1) Then Return
        GUICtrlSetBkColor($bj, 0xFFFFFF)
        $bj += 1
        If $msg = $2Button Then $bj -= 2
        If $msg = $3Button And $bj = $L3 + 1 Then $bj = $L1
        GUICtrlSetBkColor($bj, 0xFF0000)
        MsgBox(0, 0, $exe[$bj - 3], 1)
EndFunc   ;==>Go
 楼主| 发表于 2010-8-12 23:54:14 | 显示全部楼层
Case $1Button To $2Button
Go($msg)
Case $3Button
MsgBox(0, 0, $exe[$bj - 3], 1)
-------------------------------------------
正確!我的問題已解決
感謝板主afan 不厭其煩 解說

另有一篇 關於 導入進度條?  望請解答.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-29 15:21 , Processed in 0.100587 second(s), 30 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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