找回密码
 加入
搜索
查看: 4581|回复: 9

[GUI管理] (已解决)关于自定义gui的超时问题

  [复制链接]
发表于 2013-3-24 06:55:03 | 显示全部楼层 |阅读模式
本帖最后由 aassddffgg961 于 2013-3-24 16:04 编辑

老帖无人只能开新帖。发现论坛有个有趣的现象,大家都只关注没人答复的帖子,有人答复的帖子后续问题就没人答复了。。。

具体是这样的,我想制作两个输入栏,输入栏有默认数据,如果对方10秒钟没在窗口动鼠标或者键盘就使用默认数据并显示下一个输入栏。如果动鼠标或者键盘就重新倒计时或者停止倒计时。我原来的代码如下,因是菜鸟,代码灰常简陋,见笑了。
     #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <StaticConstants.au3>
    Example1()
    Example2()


    Func Example1()
        Local $msg,$Button_1,$Button_2,$open,$answer
        GUICreate("123",650,200,-1,-1)
            GUISetFont(25)
            GUICtrlCreateLabel("654879",3,5,650,30)
            $open=GUICtrlCreateInput("0101",100,70, 300, 35)
            GUISetFont(10)
            $Button_1 =GUICtrlCreateButton("确定",120, 115, 70, 40)
            GUICtrlSetState(-1, $GUI_FOCUS)
            $Button_2 =GUICtrlCreateButton("取消", 260,115,70,40)
            GUISetState()      
            GUISetState(@SW_SHOW)
           
        While 1
            $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    Exit
                            Case $msg = $Button_2
                    Exit       
                Case $msg = $Button_1
                                    $answer=GUICtrlRead($open)
                                    FileDelete(@ScriptDir&"\test.txt")
                    FileOpen("test.txt", 1)
                    FileWrite("test.txt","321")
                                    FileWrite("test.txt",$answer)
                        ExitLoop
                
            EndSelect
        WEnd

        GUIDelete()
    EndFunc  ;==>Example


    Func Example2()
              Local $msg2,$Button_3,$Button_4,$open2,$answer2
            GUICreate("456",600,200,-1,-1)
                GUISetFont(25)
                GUICtrlCreateLabel("987",3,5,650,30)
                $open2=GUICtrlCreateInput("abc",100,70, 300, 35)
            GUISetFont(10)
            $Button_3 =GUICtrlCreateButton("确定", 120, 115, 70, 40)
            GUICtrlSetState(-1, $GUI_FOCUS)
            $Button_4 =GUICtrlCreateButton("取消", 260,115,70,40)
            GUISetState()      
            GUISetState(@SW_SHOW)
           
        While 1
            $msg2= GUIGetMsg()
            Select
                Case $msg2= $GUI_EVENT_CLOSE
                    Exit
                Case $msg2= $Button_3
                                    $answer2=GUICtrlRead($open2)
                    FileOpen("test.txt", 1)
                    FileWrite("test.txt"," 666")
                    FileWrite("test.txt",$answer2)
                                    ExitLoop
                Case $msg2= $Button_4
                    Exit
            EndSelect
        WEnd

        GUIDelete()
    EndFunc    
发表于 2013-3-24 11:13:46 | 显示全部楼层
不是没人答复,是你完全不懂得学习。
http://www.autoitx.com/thread-37666-1-1.html
 楼主| 发表于 2013-3-24 12:05:35 | 显示全部楼层
回复 2# afan


    好吧,我很笨。那个问题第一次提问时是想看别人举个例,然后自己再应变为两个。结果我的能力太低,实在想不通要怎么在“func”里面注册时间组件或者怎么在外边注册时间组件在里边调用。

而”liongodmien“的例子干脆是个死循环,无论点确定或者退出都重新计时。弄个错误的例子俺这菜鸟咋学习呀?
发表于 2013-3-24 12:12:50 | 显示全部楼层
回复 3# aassddffgg961


    为什么不在一个界面安排两个输入框?
发表于 2013-3-24 12:29:12 | 显示全部楼层
;如果 Autoit3 版本低于 3.3.3.1,需将"AdlibRegister"替换为"AdlibEnable"、"AdlibUnRegister"替换为"AdlibDisable"

Global $time = 10
Global $iInput0, $iInput1, $btn0, $btn1

GUICreate('xxx', 300, 100, -1, -1)
GUICtrlCreateLabel('这是一段字符xxxxxxxxxxxx', 20, 20, 200, 30)
GUICtrlSetColor(-1, 0xFF)
$iInput0 = GUICtrlCreateInput('aaa', 10, 40, 120, 20)
$iInput1 = GUICtrlCreateInput('222', 150, 40, 120, 20)
$btn0 = GUICtrlCreateButton('确定(' & $time & ')', 50, 70, 80, 22)
GUICtrlSetState(-1, 0x100) ;$GUI_FOCUS = 0x100
$btn1 = GUICtrlCreateButton('取消', 150, 70, 80, 22)

GUISetState()
AdlibRegister("_timer", 1000)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3, $btn1
                        Exit
                Case -7, -9
                        AdlibUnRegister()
                        GUICtrlSetData($btn0, '确定')
                Case $btn0
                        _Go()
        EndSwitch
WEnd

Func _timer()
        $time -= 1
        GUICtrlSetData($btn0, '确定(' & $time & ')')
        If $time <= 0 Then
                AdlibUnRegister()
                _Go()
        EndIf
EndFunc   ;==>_timer

Func _Go()
        Local $sIpu1 = GUICtrlRead($iInput0)
        Local $sIpu2 = GUICtrlRead($iInput1)
        MsgBox(0, 0, '左框:' & $sIpu1 & @LF & '右框:' & $sIpu2 & @LF & '该干嘛用干嘛用去~', 3)
        ;FileWrite(@ScriptDir & '\test.txt', $sIpu1 & @CRLF)
        ;FileWrite(@ScriptDir & '\test.cmd', $sIpu2 & @CRLF)
        Exit
EndFunc   ;==>_Go
 楼主| 发表于 2013-3-24 15:37:21 | 显示全部楼层
回复 4# afan


    额。。。钻牛角尖了。。。。再一个就是分两个画面整洁些,毕竟介绍语不少。担心屏幕小显示不全。最主要还是想学习。看如果这种情况能怎样编写。

还有请问”liongodmien“的例子正确编写是如何编写?谢谢。
发表于 2013-3-24 15:41:21 | 显示全部楼层
回复 6# aassddffgg961


    这不科学,完毕

评分

参与人数 1金钱 +10 收起 理由
aassddffgg961 + 10

查看全部评分

 楼主| 发表于 2013-3-24 15:48:57 | 显示全部楼层
回复 7# afan


    。。。好吧,那请问”liongodmien“举的例子正确的写法是什么?我想看懂他。谢谢。

另外论坛咋没手机版的?用手机看好费劲。
发表于 2013-3-24 15:57:42 | 显示全部楼层
回复  afan


    。。。好吧,那请问”liongodmien“举的例子正确的写法是什么?我想看懂他。谢谢。
...
aassddffgg961 发表于 2013-3-24 15:48



    你可以等他修复…
ps, 他的你更会看不懂

评分

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

查看全部评分

 楼主| 发表于 2013-3-24 16:01:27 | 显示全部楼层
好吧,不知道他什么时候才回答,估计帖子沉到他看不见了。本帖使命基本完成。谢谢A版。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 04:33 , Processed in 0.092674 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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