找回密码
 加入
搜索
查看: 3403|回复: 6

[IE类操作] 【已解决】我这个程序总是卡死,如何解决

  [复制链接]
发表于 2012-8-29 07:43:54 | 显示全部楼层 |阅读模式
本帖最后由 mygys 于 2012-8-29 14:31 编辑

价格图,和文字都能显示出来,之后过一会儿就卡死
#include <Inet.au3>
#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>

#region ### START Koda GUI section ### Form=

Opt("GUIOnEventMode", 1)
$Form1_1 = GUICreate("白银价格监控", 626, 410, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Global $max = GUICtrlCreateInput("", 368, 320, 105, 21)
Global $min = GUICtrlCreateInput("", 368, 360, 105, 21)
$Button1 = GUICtrlCreateButton("确 定", 496, 328, 105, 50)
GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
GUICtrlSetColor(-1, 0x434E54)
GUISetOnEvent($Button1,"_confirm")
$Label1 = GUICtrlCreateLabel("人民币买入价", 40, 320, 76, 17)
$Label2 = GUICtrlCreateLabel("美元的买入价", 40, 360, 76, 17)
$Label3 = GUICtrlCreateLabel("", 128, 320, 76, 17)
$Label4 = GUICtrlCreateLabel("", 128, 360, 76, 17)
$Label5 = GUICtrlCreateLabel("超过这个价格告诉我", 248, 320, 112, 17)
$Label6 = GUICtrlCreateLabel("低于这个价也告诉我", 248, 360, 112, 17)
Global $oie = _IECreateEmbedded()
GUICtrlCreateObj($oie, 0, 0, 620, 305)
_Timer_SetTimer($Form1_1, 25000, "_update")
Global $autocheck = 0
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
_IENavigate($oie, 'http://www.kitco.cn/cn/live_charts/silvercny.gif')
Global $s = _INetGetSource('http://gold.hexun.com/byxh/','True')
Sleep(3000)
Global $ss=StringRegExp($s,'(?i)<td[^>]*r">([^</td>]*)</td>',3)
Global $nowvalue = $ss[0]
GUICtrlSetData($Label3, $nowvalue)
GUICtrlSetData($Label4,$ss[2])
Global $minvalue 
Global $maxvalue
While 1
Sleep(600000)
MsgBox(0,"","slll")
_update()
WEnd

Func _confirm()
        If GUICtrlRead($max) > GUICtrlRead($min) And GUICtrlRead($min) > 0 Then
                $minvalue = GUICtrlRead($min)
                $maxvalue = GUICtrlRead($max)
                $autocheck = 1
                MsgBox(4096,"OK","搞定")
        Else
                MsgBox(4096,"error","something is wrong")
        EndIf
EndFunc   ;==>_confirm


;;;建行白银网址   http://price.zhjtong.com/1_ccb_silver_740_500.png?rnd=0.8697611133102328
;(?i)<td[^>]*r">([^</td>]*)</td>
;$s = FileRead(@ScriptDir &"\hh.htm")
Func _update()
        _IEAction($oie, "refresh")
        $s = _INetGetSource('http://gold.hexun.com/byxh/', 'True')
        Sleep(3000)
        $ss = StringRegExp($s, '(?i)<td[^>]*r">([^</td>]*)</td>', 3)
        $nowvalue = $ss[0]
        If $autocheck = 1 Then
                If $nowvalue > $maxvalue Or $nowvalue < $minvalue Then
                        MsgBox(4096, "该动手了", $nowvalue)
                EndIf
        EndIf
EndFunc   ;==>_update

Func _exit()
Exit
EndFunc
发表于 2012-8-29 09:46:58 | 显示全部楼层
问题根源在于
_Timer_SetTimer($Form1_1, 25000, "_update")
 楼主| 发表于 2012-8-29 11:26:37 | 显示全部楼层
回复 2# 半芯竹


  把这行注释掉以后还是卡死啊。。
发表于 2012-8-29 12:00:10 | 显示全部楼层
43,44,45,注释掉
 楼主| 发表于 2012-8-29 12:39:48 | 显示全部楼层
回复 4# seniors


    真的可以了,谢谢。。
是不是调用_update()两次引起的啊
发表于 2012-8-29 13:04:53 | 显示全部楼层
本帖最后由 seniors 于 2012-8-29 13:11 编辑
回复  seniors


    真的可以了,谢谢。。
是不是调用_update()两次引起的啊
mygys 发表于 2012-8-29 12:39

_Timer_SetTimer($Form1_1, 25000, "_update")这句是每25秒(25000毫秒)一次

While 1
Sleep(600000)
MsgBox(0,"","slll")
_update()
WEnd
而这几句是主循环,第一句就睡觉了600秒,你让他怎么睡觉啊 ,第二句也会停,第三句重复

63行的Func _update()
应该改成Func _update($hWnd, $iMsg, $iTimerId, $iTime)
这个_update函数里最好不要出现MsgBox(4096, "该动手了", $nowvalue)
不然满足条件了25秒跳一次,你不在的话机器要跳窗口跳死的
 楼主| 发表于 2012-8-29 14:28:55 | 显示全部楼层
回复 6# seniors


    其实我想让他10分钟更新一次,试了两种办法。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-14 06:35 , Processed in 0.086401 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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