While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Xinzhengdongzhan
$some = _IECreate("http://www.baid.com", 0, 0)
$sText = _IEBodyReadText($some)
If StringInStr($sText, "无法显示网页") Then
_IENavigate($oIE, "http://192.168.1.150/")
Else
_IENavigate($oIE, "http://www.google.com/")
EndIf
Case $msg = $GUI_Button_Naiguan
$some = _IECreate("http://www.baid.com", 0, 0)
$sText = _IEBodyReadText($some)
If StringInStr($sText, "无法显示网页") Then
_IENavigate($oIE, "http://192.168.1.151/")
Else
_IENavigate($oIE, "http://www.gougou.com/")
EndIf
EndSelect
这样写出来,虽然能够顺利运行,代码却不够精简!运行程序,会有小卡的表现
所以想$some = _IECreate("http://www.baid.com", 0, 0)
$sText = _IEBodyReadText($some)
If StringInStr($sText, "无法显示网页") Then
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Xinzhengdongzhan
_IENavigate($oIE, "http://www.google.com/")
Case $msg = $GUI_Button_Naiguan
_IENavigate($oIE, "http://www.gougou.com/")
EndSelect
else
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Xinzhengdongzhan
_IENavigate($oIE, "http://192.168.1.150/")
Case $msg = $GUI_Button_Naiguan
_IENavigate($oIE, "http://192.168.1.151/")
EndSelect
下面的代码只是想出来的,只是不能运行,两个选择结构不能运行
希望大家帮帮忙看看,该怎么实现 |