找回密码
 加入
搜索
查看: 1664|回复: 7

一个困扰了很久的问题!谢谢了。。

[复制链接]
发表于 2008-11-2 02:33:08 | 显示全部楼层 |阅读模式
代码如下:
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("GUICloseOnESC",1)

$Form1 = GUICreate("test",100,100, -1, -1,$ws_popup,$WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case 0
                        Sleep(5000)
                        Exit
        EndSwitch
WEnd

运行了之后,按ESC无反应,还是要等5秒才退出
怎么解决?

[ 本帖最后由 waynelue 于 2008-11-2 13:02 编辑 ]
发表于 2008-11-2 02:49:17 | 显示全部楼层

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("GUICloseOnESC",1)

$Form1 = GUICreate("test",100,100, -1, -1,$ws_popup,$WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
              
        EndSwitch
WEnd
 楼主| 发表于 2008-11-2 03:04:14 | 显示全部楼层
谢谢叁恨的解答,不好意思,我要的是GUI在显示的时候如果有按下ESC就马上退出,如果没任何动作就过5秒钟后自动退出,该如何做?
 楼主| 发表于 2008-11-2 03:09:29 | 显示全部楼层
这两天一直在找有关的贴子,呵呵
直到刚才找到一编,用热键定义退出
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("GUICloseOnESC",1)

$Form1 = GUICreate("test",100,100, -1, -1,$ws_popup,$WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
HotKeySet("{ESC}", "exitgui")

Sleep(5000)
Exit

Func exitgui()
Exit
Endfunc

可就是不知道其它的方法了,谁有不同的方法都可以提出来啊,集思广义嘛
发表于 2008-11-2 08:32:37 | 显示全部楼层
第一种方式:
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#Include <Timers.au3>
#NoTrayIcon
Opt("GUICloseOnESC",1)

$Form1 = GUICreate("test",100,100, -1, -1,$ws_popup,$WS_EX_TOOLWINDOW)
AdlibEnable("out",5000)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
              
        EndSwitch
WEnd

Func out()
Exit
EndFunc

第二种方式:
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#Include <Timers.au3>
#NoTrayIcon
Opt("GUICloseOnESC",1)

$Form1 = GUICreate("test",100,100, -1, -1,$ws_popup,$WS_EX_TOOLWINDOW)
$starttime = _Timer_Init()
GUISetState(@SW_SHOW)

While 1
if _Timer_Diff($starttime)>5000 Then
Exit
EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
              
        EndSwitch
WEnd
发表于 2008-11-2 12:11:02 | 显示全部楼层
有可能是最简的方法:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("GUICloseOnESC", 1)

$Form1 = GUICreate("test", 100, 100, -1, -1, $ws_popup, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
$T = TimerInit()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case 0
                        If TimerDiff($T) >= 5000 Then Exit
        EndSwitch
WEnd
 楼主| 发表于 2008-11-2 12:56:17 | 显示全部楼层
谢谢5L和6L和精彩解答!看来方法还是不少啊,呵呵!慢慢研究这几种方法的优劣~~~刚学不久,很多函数都不知道,看来以后得多看帮助了

[ 本帖最后由 waynelue 于 2008-11-2 13:01 编辑 ]
发表于 2008-11-2 13:25:18 | 显示全部楼层
狮子的函数很精彩
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-2 16:34 , Processed in 0.070442 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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