找回密码
 加入
搜索
查看: 1950|回复: 1

[系统综合] 在执行一个死循环期间如何响应托盘的点击事件?

[复制链接]
发表于 2011-7-2 15:48:11 | 显示全部楼层 |阅读模式
程序开始时要执行一个死循环去监视某个窗口是否存在,但我又想在执行监视循环期间能响应托盘的点击事件,是否要用到多线程才行?
发表于 2011-7-2 21:36:43 | 显示全部楼层
如果是这样, 为何不注册一个AdlibRegister 函数来帮你呢,这个可不会死循环;
当然,是看你的用法!下面是我的想法:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $winexists=0

AdlibRegister('_winexists',500)
AdlibRegister('_openthenotepad',3000)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func _WinExists()
        If WinExists('无标题 - 记事本') Then
                $winexists=1
                MsgBox(64,'提示','现在窗口出现了,你可以使用变量 winexists 传递消息')
                AdlibUnRegister('_winexists')
                AdlibUnRegister('_openthenotepad')
                WinClose('无标题 - 记事本')
        EndIf
EndFunc

Func _openthenotepad()
        Run('notepad.exe')
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 03:36 , Processed in 0.070438 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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