#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
;~ #NoTrayIcon
Global $Flg=True
;~ HotKeySet("{ESC}", "Terminate")
;~ HotKeySet('{F9}', '_HIShow')
Dim $H = True
Local $GUI_Button_1, $GUI_Button_2, $GUI_Button_stop, $GUIActiveX,$oIE
_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()
GUICreate("test。 F9键隐藏/显示窗口,ESC键退出", 300, 300, @DesktopWidth /2, @DesktopHeight /2)
$GUIActiveX = GUICtrlCreateObj($oIE, -1, 100, 300, 200)
$GUI_Button_1 = GUICtrlCreateButton("循环1,延时1秒,不停的按停止键才能推出循环", 5, 5, 290, 25)
$GUI_Button_2 = GUICtrlCreateButton("循环2,循环一圈很快,按一次停止键就能退出", 5, 30, 290, 25)
$GUI_Button_stop = GUICtrlCreateButton("停止键,狂点才能停", 5, 60, 290, 25)
$oIE.navigate("www.baidu.com")
GUISetState()
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $GUI_Button_1
_xunhuan1()
Case $msg = $GUI_Button_2
_xunhuan2()
;~ Case $msg = $GUI_Button_stop
;~ Exit
EndSelect
WEnd
Func _xunhuan1()
if $Flg=False then $Flg=True
GUICtrlSetState($GUI_Button_1,$gui_disable)
GUICtrlSetState($GUI_Button_2,$gui_disable)
While $Flg
$oIE.navigate("www.baidu.com")
Sleep (1000) ;加了延时
WEnd
MsgBox(0,"","循环1被停止了")
GUICtrlSetState($GUI_Button_1,$gui_enable)
GUICtrlSetState($GUI_Button_2,$gui_enable)
EndFunc
Func _xunhuan2()
if $Flg=False then $Flg=True
GUICtrlSetState($GUI_Button_1,$gui_disable)
GUICtrlSetState($GUI_Button_2,$gui_disable)
While $Flg
$oIE.navigate("www.163.com") ;循环时间很短,按停止键后可以直接停止
WEnd
MsgBox(0,"","循环2被停止了")
GUICtrlSetState($GUI_Button_1,$gui_enable)
GUICtrlSetState($GUI_Button_2,$gui_enable)
EndFunc
Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
If BitAND($wParam, 0xFFFF) = $GUI_Button_stop Then $Flg = False
Return $GUI_RUNDEFMSG
EndFunc
|