找回密码
 加入
搜索
查看: 6115|回复: 9

[IE类操作] AU3假死问题:获取网页源代码期间短暂假死

  [复制链接]
发表于 2012-3-20 00:39:21 | 显示全部楼层 |阅读模式
悬赏200金钱未解决
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 361, 253, 192, 124)
GUISetOnEvent(-3, "Form1Close")
$Button1 = GUICtrlCreateButton("按钮", 86, 45, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
While 1
        Sleep(100)
WEnd
Func Button1Click()
        $a = TimerInit()
        Local $Body
        $oHTTP = ObjCreate("Msxml2.xmlhttp")
        $oHTTP.Open('GET','http://www.autoitx.com/thread-30906-1-1.html&t=' & Random(0, 1),true);
        $oHTTP.Send()
        ToolTip(TimerDiff($a))
        $Body = $oHTTP.responseBody
EndFunc
Func Form1Close()
        Exit        
EndFunc


当打开一个较大的网页时也会假死,用_INetGetSource 也会,假死的情况为拖动窗口拖不了,通讯完全阻断了

发表于 2012-3-20 01:02:05 | 显示全部楼层
把http设置成异步,很大程度上已经避免了假死。要想窗体一点也不卡,只能用多线程了。

评分

参与人数 1金钱 +20 贡献 +2 收起 理由
tryhi + 20 + 2 感谢关注

查看全部评分

 楼主| 发表于 2012-3-20 02:05:47 | 显示全部楼层
把http设置成异步,很大程度上已经避免了假死。要想窗体一点也不卡,只能用多线程了。
apprentice 发表于 2012-3-20 01:02



    正在考虑要不要用多进程。。。
发表于 2012-3-20 02:18:02 | 显示全部楼层
这个要考虑考虑了,也是代码的问题

评分

参与人数 1金钱 +20 贡献 +2 收起 理由
tryhi + 20 + 2 感谢关注

查看全部评分

发表于 2012-3-20 09:01:56 | 显示全部楼层
这个问题是所有需要网络通信的程序都面临的,自己用的话就暂时隐藏Gui吧,否则就用多进程

评分

参与人数 1金钱 +25 贡献 +2 收起 理由
tryhi + 25 + 2 多谢建议

查看全部评分

发表于 2012-3-20 09:44:28 | 显示全部楼层
本帖最后由 kxing 于 2012-3-20 09:45 编辑
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 361, 253, 192, 124)
GUISetOnEvent(-3, "Form1Close")
$Button1 = GUICtrlCreateButton("按钮", 86, 45, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
While 1
        Sleep(100)
WEnd
Func Button1Click()
        $a = TimerInit()
        Local $Body
        $oHTTP = ObjCreate("Msxml2.xmlhttp")
        $oHTTP.Open('GET','http://www.autoitx.com/thread-30906-1-1.html&t=' & Random(0, 1));
        $oHTTP.Send()
        ToolTip(TimerDiff($a))
        $Body = $oHTTP.responseBody

while not $body
;这里可以换成guigetmsg模式,这样就能响应窗口事件了
$Body = $oHTTP.responseBody
if timerdiff($a)>=3000 then exitloop;设置超时时间
wend
EndFunc
Func Form1Close()
        Exit    
EndFunc
 楼主| 发表于 2012-3-20 14:00:24 | 显示全部楼层
kxing 发表于 2012-3-20 09:44


很明显是不行,$oHTTP.Send()的时候已经阻断了所有通讯消息,你下面写什么都没用
 楼主| 发表于 2012-3-21 10:33:13 | 显示全部楼层
还是用多进程吧
发表于 2012-3-21 11:10:48 | 显示全部楼层
要不要考虑网络连通性问题。会不会更完美。O(∩_∩)O~,我不怎么懂这方面的内容。只是路过。

评分

参与人数 1金钱 +20 贡献 +2 收起 理由
tryhi + 20 + 2

查看全部评分

发表于 2012-3-21 14:05:46 | 显示全部楼层
注册消息试试

#include <WindowsConstants.au3>
#include <GuiMenu.au3>

$Form1 = GUICreate("Form1", 361, 253, 192, 124)
$Button1 = GUICtrlCreateButton("按钮", 86, 45, 75, 25)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

While 1
        Switch GUIGetMsg()
                Case $Button1
                        Button1Click()
        EndSwitch
WEnd

Func Button1Click()
        $a = TimerInit()
        Local $Body
        $oHTTP = ObjCreate("Msxml2.xmlhttp")
        $oHTTP.Open('GET', 'http://www.autoitx.com/thread-30906-1-1.html&t=' & Random(0, 1), True);
        $oHTTP.Send()
        ToolTip(TimerDiff($a))
        $Body = $oHTTP.responseBody
EndFunc   ;==>Button1Click

Func WM_SYSCOMMAND($hWnd, $sMsg, $sWParam, $slParam)
        Switch $sWParam
                Case $SC_CLOSE ;结束程序
                        Exit
        EndSwitch
EndFunc   ;==>WM_SYSCOMMAND

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-17 07:35 , Processed in 0.096183 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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