找回密码
 加入
搜索
查看: 5525|回复: 12

[AU3基础] 【已解决】3个按钮都不起作用

  [复制链接]
发表于 2015-3-11 22:10:05 | 显示全部楼层 |阅读模式
本帖最后由 dnvplj 于 2015-3-12 14:00 编辑

请问各位朋友:
存在的问题是,在到计时15秒内,3个按钮都不起作用,请问,如何让其在15秒内点击各按钮都起作用”。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)

#Region ### START Koda GUI section ### Form=
Global $gu_Form2 = GUICreate("", 392, 104, -1, -1)
Global $gu_Group1 = GUICtrlCreateGroup("", 8, 8, 377, 89)
Global $gu_Input1 = GUICtrlCreateInput("", 16, 24, 287, 21)
Global $gu_Button1 = GUICtrlCreateButton("选  择", 313, 21, 65, 25)
Global $gu_Button2 = GUICtrlCreateButton("执  行", 240, 56, 65, 30)
Global $gu_Button3 = GUICtrlCreateButton("退  出", 313, 56, 65, 30)
Global $gu_Label1 = GUICtrlCreateLabel("15秒后退出,否则请手动选择", 55, 62, 180, 20)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
Global $gu_Label1_1 = GUICtrlCreateLabel(" 5 ", 16, 62, 25, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

_Main()
Exit

Func _Main()
        Local $i
        For $i = 15 To 1 Step -1
                GUICtrlSetData($gu_Label1_1, $i)
                Sleep(1000)
                If $i = 1 Then Exit
        Next

        Local $nMsg
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                        Case $gu_Button1
                                Local $gu_Inputa1
                                $gu_Inputa1 = FileOpenDialog('选择文件', '', 'exe文件(*.exe)', 1, '', $gu_Form2)
                                GUICtrlSetData($gu_Input1, $gu_Inputa1)
                        Case $gu_Button2
                                GUISetState(@SW_HIDE, $gu_Form2)
                                RunWait("" & GUICtrlRead($gu_Input1))
                                Exit
                        Case $gu_Button3
                                Exit
                EndSwitch
        WEnd

EndFunc   ;==>_Main
发表于 2015-3-11 23:46:31 | 显示全部楼层
本帖最后由 netegg 于 2015-3-11 23:51 编辑

不对呀,你那个不可能起作用的,一直在循环着呢
发表于 2015-3-12 00:29:42 | 显示全部楼层
回复 1# dnvplj

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>



Opt("MustDeclareVars", 1)

#Region ### START Koda GUI section ### Form=
Global $gu_Form2 = GUICreate("", 392, 104, -1, -1)
Global $gu_Group1 = GUICtrlCreateGroup("", 8, 8, 377, 89)
Global $gu_Input1 = GUICtrlCreateInput("", 16, 24, 287, 21)
Global $gu_Button1 = GUICtrlCreateButton("?  ?", 313, 21, 65, 25)
Global $gu_Button2 = GUICtrlCreateButton("?  行", 240, 56, 65, 30)
Global $gu_Button3 = GUICtrlCreateButton("退  出", 313, 56, 65, 30)
Global $gu_Label1 = GUICtrlCreateLabel("15秒后退出,否??手???", 55, 62, 180, 20)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
Global $gu_Label1_1 = GUICtrlCreateLabel(" 5 ", 16, 62, 25, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $Fist=@SEC
_Main()
Exit

Func _Main()

        Local $nMsg
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                        Case $gu_Button1
                                Local $gu_Inputa1
                                $gu_Inputa1 = FileOpenDialog('??文件', '', 'exe文件(*.exe)', 1, '', $gu_Form2)
                                GUICtrlSetData($gu_Input1, $gu_Inputa1)
                        Case $gu_Button2
                                GUISetState(@SW_HIDE, $gu_Form2)
                                RunWait("" & GUICtrlRead($gu_Input1))
                                Exit
                        Case $gu_Button3
                                Exit
                                EndSwitch
                         Global $NOW=@SEC
                         GUICtrlSetData($gu_Label1_1, ($NOW-$Fist))
                         If ($NOW-$Fist) = 15 Then Exit                        
        WEnd

EndFunc   ;==>_Main

评分

参与人数 1金钱 +10 收起 理由
dnvplj + 10 乐于助人

查看全部评分

 楼主| 发表于 2015-3-12 08:06:14 | 显示全部楼层
本帖最后由 dnvplj 于 2015-3-12 09:11 编辑

回复 3# kk_lee69
朋友感谢你的回复,问题解决了,但还有一个小问题,就是:数字显示能否做到01、02...15这样显示吗?
发现问题:1、不是到计时.2、数字显示有晃动.3、有时发生错误(下图)

本帖子中包含更多资源

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

×
发表于 2015-3-12 09:30:34 | 显示全部楼层
回复 4# dnvplj

因為我的做法是 取秒數相減   這是偷懶的方法

真的 要正確秒數  要設定 定時的方法 處理

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
 
 
 
Opt("MustDeclareVars", 1)
 
#Region ### START Koda GUI section ### Form=
Global $gu_Form2 = GUICreate("", 392, 104, -1, -1)
Global $gu_Group1 = GUICtrlCreateGroup("", 8, 8, 377, 89)
Global $gu_Input1 = GUICtrlCreateInput("", 16, 24, 287, 21)
Global $gu_Button1 = GUICtrlCreateButton("?  ?", 313, 21, 65, 25)
Global $gu_Button2 = GUICtrlCreateButton("?  行", 240, 56, 65, 30)
Global $gu_Button3 = GUICtrlCreateButton("退  出", 313, 56, 65, 30)
Global $gu_Label1 = GUICtrlCreateLabel("15秒后退出,否??手???", 55, 62, 180, 20)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
Global $gu_Label1_1 = GUICtrlCreateLabel(" 0 ", 16, 62, 25, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibRegister ( "TIME" , 1000 )
Global $T=0
_Main()
Exit
 
Func _Main()
 
        Local $nMsg
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                        Case $gu_Button1
                                Local $gu_Inputa1
                                $gu_Inputa1 = FileOpenDialog('??文件', '', 'exe文件(*.exe)', 1, '', $gu_Form2)
                                GUICtrlSetData($gu_Input1, $gu_Inputa1)
                        Case $gu_Button2
                                GUISetState(@SW_HIDE, $gu_Form2)
                                RunWait("" & GUICtrlRead($gu_Input1))
                                Exit
                        Case $gu_Button3
                                Exit
                                EndSwitch
            
        WEnd
 
EndFunc   ;==>_Main

Func TIME()
IF $T >15  THEN Exit
        
If $T =0 Then
        GUICtrlSetData($gu_Label1_1,  $T )
Else
        GUICtrlSetData($gu_Label1_1,  StringFormat('%02d',$T) )
EndIf
$T=$T+1
EndFunc
 楼主| 发表于 2015-3-12 11:49:52 | 显示全部楼层
回复 5# kk_lee69
能否让计时在“选择和执行”时,退出,不然的话计时到10秒后,在操作就来不及了。如果延长计时就没什么意义了。
发表于 2015-3-12 13:30:37 | 显示全部楼层
这样才好玩

本帖子中包含更多资源

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

×
发表于 2015-3-12 13:35:26 | 显示全部楼层
Opt('MustDeclareVars', 1)

Global $time = 15, $gu_Form2, $gu_Input1, $gu_Button1, $gu_Button2, $gu_Button3, $gu_Label1, $gu_Label1_1

$gu_Form2 = GUICreate('', 392, 104, -1, -1)
GUICtrlCreateGroup('', 8, 8, 377, 89)
$gu_Input1 = GUICtrlCreateInput('', 16, 24, 287, 21)
$gu_Button1 = GUICtrlCreateButton('选  择', 313, 21, 65, 25)
$gu_Button2 = GUICtrlCreateButton('执  行', 240, 56, 65, 30)
$gu_Button3 = GUICtrlCreateButton('退  出', 313, 56, 65, 30)
$gu_Label1 = GUICtrlCreateLabel('秒后退出(界面点击将停止倒计时)', 45, 62, 190, 20)
GUICtrlSetFont(-1, 11, 400, 0, 'MS Sans Serif')
$gu_Label1_1 = GUICtrlCreateLabel($time, 16, 58, 25, 25, 0x0002)
GUICtrlSetFont(-1, 15, 800, 0, 'MS Sans Serif')
GUICtrlSetColor(-1, 0xFF0000)
GUISetState()
_Main()

Func _Main()
        AdlibRegister("_timer", 1000)
        Local $nMsg
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case -3
                                Exit
                        Case -7, -9
                                AdlibUnRegister()
                                GUICtrlDelete($gu_Label1_1)
                                GUICtrlDelete($gu_Label1)

                        Case $gu_Button1
                                Local $gu_Inputa1
                                $gu_Inputa1 = FileOpenDialog('选择文件', '', 'exe文件(*.exe)', 1, '', $gu_Form2)
                                GUICtrlSetData($gu_Input1, $gu_Inputa1)

                        Case $gu_Button2
                                Run(GUICtrlRead($gu_Input1))
                                Exit

                        Case $gu_Button3
                                Exit
                EndSwitch
        WEnd
EndFunc   ;==>_Main

Func _timer()
        $time -= 1
        GUICtrlSetData($gu_Label1_1, $time)
        If $time <= 0 Then
                AdlibUnRegister()
                Exit
        EndIf
EndFunc   ;==>_timer

评分

参与人数 1金钱 +10 收起 理由
dnvplj + 10 乐于助人

查看全部评分

发表于 2015-3-12 13:41:40 | 显示全部楼层
回复 6# dnvplj

給你的語法 忘了加 AdlibUnRegister()

這個部分的處理  早上開會 沒時間 寫~~~

樓上 afan 老大已經給你代碼了~~
 楼主| 发表于 2015-3-12 13:58:17 | 显示全部楼层
回复 8# afan
感谢回复,问题解决了,谢谢。
 楼主| 发表于 2015-3-12 16:06:10 | 显示全部楼层
回复 8# afan
数字能否做到01、02...15这样显示吗?
发表于 2015-3-12 16:25:37 | 显示全部楼层
回复 11# dnvplj


    我已经做了右对齐处理了,还用得着前面补0占位吗?
需要的话用 StringFomat() 简单处理下即可
 楼主| 发表于 2015-3-12 16:32:44 | 显示全部楼层
回复 12# afan
谢谢,我自己处理一下。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 16:18 , Processed in 0.188889 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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