【已解决】我这个程序总是卡死,如何解决
本帖最后由 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
GUICtrlSetData($Label3, $nowvalue)
GUICtrlSetData($Label4,$ss)
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
If $autocheck = 1 Then
If $nowvalue > $maxvalue Or $nowvalue < $minvalue Then
MsgBox(4096, "该动手了", $nowvalue)
EndIf
EndIf
EndFunc ;==>_update
Func _exit()
Exit
EndFunc
问题根源在于
_Timer_SetTimer($Form1_1, 25000, "_update") 回复 2# 半芯竹
把这行注释掉以后还是卡死啊。。 43,44,45,注释掉 回复 4# seniors
真的可以了,谢谢。。{:face (411):}
是不是调用_update()两次引起的啊 本帖最后由 seniors 于 2012-8-29 13:11 编辑
回复seniors
真的可以了,谢谢。。
是不是调用_update()两次引起的啊
mygys 发表于 2012-8-29 12:39 http://www.autoitx.com/images/common/back.gif
_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秒跳一次,你不在的话机器要跳窗口跳死的 回复 6# seniors
其实我想让他10分钟更新一次,试了两种办法。。。
页:
[1]