【已解决】3个按钮都不起作用
本帖最后由 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
本帖最后由 netegg 于 2015-3-11 23:51 编辑
不对呀,你那个不可能起作用的,一直在循环着呢 回复 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 本帖最后由 dnvplj 于 2015-3-12 09:11 编辑
回复 3# kk_lee69
朋友感谢你的回复,问题解决了,但还有一个小问题,就是:数字显示能否做到01、02...15这样显示吗?
发现问题:1、不是到计时.2、数字显示有晃动.3、有时发生错误(下图)
回复 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 >15THEN Exit
If $T =0 Then
GUICtrlSetData($gu_Label1_1,$T )
Else
GUICtrlSetData($gu_Label1_1,StringFormat('%02d',$T) )
EndIf
$T=$T+1
EndFunc 回复 5# kk_lee69
能否让计时在“选择和执行”时,退出,不然的话计时到10秒后,在操作就来不及了。如果延长计时就没什么意义了。 这样才好玩
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
回复 6# dnvplj
給你的語法 忘了加 AdlibUnRegister()
這個部分的處理早上開會 沒時間 寫~~~
樓上 afan 老大已經給你代碼了~~ 回复 8# afan
感谢回复,问题解决了,谢谢。 回复 8# afan
数字能否做到01、02...15这样显示吗? 回复 11# dnvplj
我已经做了右对齐处理了,还用得着前面补0占位吗?
需要的话用 StringFomat() 简单处理下即可 回复 12# afan
谢谢,我自己处理一下。
页:
[1]