找回密码
 加入
搜索
楼主: superflq

复杂的 while循环 退出问题?【已完美解决,见最后一楼】

  [复制链接]
 楼主| 发表于 2009-2-5 13:32:21 | 显示全部楼层
原帖由 ceoguang 于 2009-1-17 03:56 发表
呵呵,我再来增加个难题
#include
#include
#include

$Form = GUICreate("例子一", 307, 81, -1, -1)
$Button1 = GUICtrlCreateButton("开始", 32, 24, 97, 33, 0)
$Button2 = GUICtrlCreateButton("停 ...



fit 本来就是每500毫秒运行一次的,楼上给的问题存在逻辑错误
如果要实现楼上的问题,可以加上一个判断,可以变成这样
#include 
#include 
#include 
$Form = GUICreate("例子一", 307, 81, -1, -1)
$Button1 = GUICtrlCreateButton("开始", 32, 24, 97, 33, 0)
$Button2 = GUICtrlCreateButton("停止", 176, 24, 97, 33, 0)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_TIMER, "WM_TIMER")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Global $i = 0
$iTimeProgres4 = _Timer_SetTimer($Form, 100)
Case $Button2
_Timer_KillTimer($Form, $iTimeProgres4)
MsgBox(0, "结果", $i)
EndSwitch
WEnd

Func WM_TIMER($hWnd, $iMsg, $iwParam, $ilParam)
Switch _Timer_GetTimerID($iwParam)
Case $iTimeProgres4
fit()
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_TIMER

Func fit()
If $i >= 100 Then
_Timer_KillTimer($Form, $iTimeProgres4)
MsgBox(0, "结果", $i)
Return
EndIf
$i += 1
TrayTip("脚本正在循环中", "目的是第" & $i & "次", 10, 1)
EndFunc ;==>fit


[ 本帖最后由 superflq 于 2009-2-5 13:44 编辑 ]
发表于 2009-12-27 17:32:43 | 显示全部楼层
非常感谢 _Timer_SetTimer 的代码

这个问题困扰我很久了...
发表于 2010-10-8 23:28:37 | 显示全部楼层
进来学习。。
发表于 2011-2-24 02:07:18 | 显示全部楼层
学习 留名 明天按
发表于 2011-3-13 03:49:48 | 显示全部楼层
学习了  
发表于 2013-4-13 18:03:20 | 显示全部楼层
要试试看。
发表于 2013-6-24 12:21:11 | 显示全部楼层
Global Const $GUI_EVENT_CLOSE = -3
Global Const $GUI_EVENT_MINIMIZE = -4
Global Const $GUI_EVENT_R ...
superflq 发表于 2008-12-12 15:10

学习了 谢谢分享啊
发表于 2014-4-27 17:46:01 | 显示全部楼层
顶了!学到东西了,谢谢各位前辈!
发表于 2014-12-21 02:58:18 | 显示全部楼层
学习学习,感谢!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-12 19:10 , Processed in 0.073891 second(s), 13 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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