如何两个gui窗口同时显示出来?
如下的代码,如何点托盘菜单让“配置”窗口和“关于“窗口”同时显示在屏幕上?知道au3难以支持多线程,但记得伟大的p版说过用汇编来实现,不懂汇编,怎么实现?
#NoTrayIcon
TrayMenu()
While True
Sleep(200)
WEnd
Func TrayMenu()
$TrayIconHide = 0
Opt("TrayIconHide", 0)
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode",1)
TraySetClick(16)
$ConfigGUI = TrayCreateItem("配置", -1, 0, 1)
TrayItemSetOnEvent($ConfigGUI, "ConfigGUI")
$AboutProgram = TrayCreateItem("关于", -1, 2, 1)
TrayItemSetOnEvent($AboutProgram, "AboutProgram")
$ExitProgram = TrayCreateItem("退出", -1, 3, 1)
TrayItemSetOnEvent($ExitProgram, "ExitProgram")
TraySetState()
EndFunc
Func ConfigGUI()
GUICreate("Config")
$ok = GUICtrlCreateButton("Hi:", 10, 10, 30, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
ExitLoop
Case $ok
ExitLoop
EndSwitch
WEnd
GUIDelete()
EndFunc
Func AboutProgram()
GUICreate("About")
$About = GUICtrlCreateLabel("This is About", 10, 10, 100, 20)
$ok = GUICtrlCreateButton("Ok", 10, 50, 30, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
ExitLoop
Case $ok
ExitLoop
EndSwitch
WEnd
GUIDelete()
EndFunc
Func ExitProgram()
Exit
EndFunc
两个函数写成一个就可以了 回复 2# manlty
这样,明显不合实际需求呀! 用事件驱动模式。 本帖最后由 yhxhappy 于 2011-3-6 17:22 编辑
楼主的贴的代码语法高亮是什么做的?#NoTrayIcon
#include <Constants.au3>
#include <GUIConstantsEx.au3>
Opt("TrayMenuMode",1) ; 不显示默认菜单(脚本暂停/退出).
Opt("GUIOnEventMode", 1) ;事件模式
Global $ConfigGUI, $ok1, $ok2
$ConfigProgram = TrayCreateItem("配置", -1, 0, 1)
$AboutProgram = TrayCreateItem("关于", -1, 2, 1)
$ExitProgram = TrayCreateItem("退出", -1, 3, 1)
TraySetClick(16)
TraySetState()
While 1
$msg = TrayGetMsg()
Switch $msg
Case $ConfigProgram
ConfigGUI()
Case $AboutProgram
AboutProgram()
Case $ExitProgram
Exit
Case $TRAY_EVENT_PRIMARYDOWN
ConfigGUI()
AboutProgram()
EndSwitch
WEnd
Func ConfigGUI($a = 0)
$ConfigGUI = GUICreate("Config")
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI")
$ok1 = GUICtrlCreateButton("Hi:", 10, 10, 30, 20)
GUICtrlSetOnEvent(-1, "_GUI")
GUISetState()
EndFunc
Func AboutProgram()
$Pos = WinGetPos($ConfigGUI)
If $Pos = 0 Then
$x = Default
$y = Default
Else
$x = $Pos+$Pos+10
$y = $Pos
EndIf
GUICreate("About", -1, -1, $x, $y)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI")
$About = GUICtrlCreateLabel("This is About", 10, 10, 100, 20)
$ok2 = GUICtrlCreateButton("Ok", 10, 50, 30, 20)
GUICtrlSetOnEvent(-1, "_GUI")
GUISetState()
EndFunc
Func _GUI()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE, $ok1, $ok2
GUIDelete(@GUI_WinHandle)
EndSwitch
EndFunc 回复 5# yhxhappy
点击添加代码的那个符号,在底下的编辑框有【code】【/code】 这样的字符
把其中的code改为AU3 即可 一个和尚挑水喝,两个和尚抬水喝,三个和尚没水喝这个道理大家要明啊!
lol!!!
#NoTrayIcon
Opt("GUIOnEventMode", 1)
TrayMenu()
While True
Sleep(200)
WEnd
Func TrayMenu()
$TrayIconHide = 0
Opt("TrayIconHide", 0)
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
TraySetClick(16)
$ConfigGUI = TrayCreateItem("配置", -1, 0, 1)
TrayItemSetOnEvent($ConfigGUI, "ConfigGUI")
$AboutProgram = TrayCreateItem("关于", -1, 2, 1)
TrayItemSetOnEvent($AboutProgram, "AboutProgram")
$ExitProgram = TrayCreateItem("退出", -1, 3, 1)
TrayItemSetOnEvent($ExitProgram, "ExitProgram")
TraySetState()
EndFunc ;==>TrayMenu
Func ConfigGUI()
GUICreate("Config")
GUISetOnEvent(-3, "GuiEvent")
$ok = GUICtrlCreateButton("Hi:", 10, 10, 30, 20)
GUISetState()
EndFunc ;==>ConfigGUI
Func AboutProgram()
GUICreate("About")
GUISetOnEvent(-3, "GuiEvent")
$About = GUICtrlCreateLabel("This is About", 10, 10, 100, 20)
$ok = GUICtrlCreateButton("Ok", 10, 50, 30, 20)
GUISetState()
EndFunc ;==>AboutProgram
Func GuiEvent()
Switch @GUI_CtrlId
Case -3
GUIDelete(@GUI_WinHandle)
EndSwitch
EndFunc
Func ExitProgram()
Exit
EndFunc ;==>ExitProgram
页:
[1]