|
发表于 2016-5-10 12:57:13
|
显示全部楼层
本帖最后由 chzj589 于 2016-5-10 14:42 编辑
回复 7# kk_lee69
那这样呢?
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("+!z", "GUI_Button1") ; Shift-Alt-z
HotKeySet("+!x", "GUI_Button2") ; Shift-Alt-z
Global $Mainb, $Button1, $Button2
GUI_Main()
While 1
Sleep(20)
WEnd
Func GUI_Main()
$Main = GUICreate("TEST", 500, 500, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainClose")
$Button1 = GUICtrlCreateButton('关闭子窗口', 10, 10, 100, 25)
GUICtrlSetOnEvent($Button1, "GUI_Button1")
$Button2 = GUICtrlCreateButton('打开子窗口', 10, 10, 100, 25)
GUICtrlSetOnEvent($Button2, "GUI_Button2")
GUICtrlSetState($Button2, $GUI_HIDE)
GUICtrlCreateLabel("键盘组合键:<Shift-Alt-z> 关闭子窗口", 10,45, 350, 25, 0)
GUICtrlSetFont(-1, 12, 600, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x009900)
GUICtrlCreateLabel("键盘组合键:<Shift-Alt-x> 打开子窗口", 10,85, 350, 25, 0)
GUICtrlSetFont(-1, 12, 600, 0, "Times New Roman")
GUICtrlSetColor(-1, 0xff0000)
GUISetState()
$Mainb = GUICreate("子窗口", 300, 200, 500, 400, $WS_SYSMENU, -1, $Main)
GUISetOnEvent($Mainb, "GUI_Button1")
GUISetState()
EndFunc ;==>GUI_Main
Func MainClose()
Exit
EndFunc ;==>MainClose
Func GUI_Button1()
MsgBox(0, "关闭子窗口", "是否确定关闭子窗口??")
GUISetState(@SW_HIDE, $Mainb)
GUICtrlSetState($Button1, $GUI_HIDE)
GUICtrlSetState($Button2, $GUI_SHOW)
EndFunc ;==>GUI_Button1
Func GUI_Button2()
MsgBox(0, "打开子窗口", "是否确定打开子窗口??")
GUISetState(@SW_SHOW, $Mainb)
GUICtrlSetState($Button2, $GUI_HIDE)
GUICtrlSetState($Button1, $GUI_SHOW)
EndFunc ;==>GUI_Button2 |
|