找回密码
 加入
搜索
查看: 1864|回复: 8

[AU3基础] 在鼠标有效应的模式下如何建立无限循环?(已解决)

[复制链接]
发表于 2018-7-19 17:41:19 | 显示全部楼层 |阅读模式
本帖最后由 qsy666888 于 2018-7-20 08:28 编辑

在鼠标有效应的模式下如何建立无限循环?使其他们互不干扰
如下:1、label  显示数字从1开始,每6秒加1
          2、鼠标移动到按钮上有效应,弹出消息框。
现在两者均能体现,但有互相有干扰,遇到这种情况如何处理呢,求大神门赐教。




#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $i = 1,$B = 1
Opt("GUIOnEventMode",1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("有鼠标效应的时候如何加循环段", 367, 147)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Label1 = GUICtrlCreateLabel("", 48, 16, 60, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Button1", 48, 56, 115, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
  $Info = GUIGetCursorInfo($Form1)
  If Not @error Then
  If  $info[4] = $Button1 And $B = 1 Then 
   MsgBox(0,0,'鼠标在按钮上')
   $B = 0
  ElseIf $info[4] <> $Button1 And $B = 0 Then
   ;MsgBox(0,0,'鼠标已离开按钮')
   $B = 1
  EndIf 
    EndIf   
 xh()
WEnd
Func _Exit()
Exit
EndFunc   ;==>_Exit
Func xh()
       GUICtrlSetData($Label1,$i)
       $i+= 1    
       Sleep(6000)
EndFunc



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2018-7-19 22:31:42 | 显示全部楼层
本帖最后由 kk_lee69 于 2018-7-19 22:40 编辑

看不出來你的影響是甚麼..........

會有影響是 循環模式 與 事件模式 的相互干擾

或者 SLEEP 造成的影響
发表于 2018-7-19 22:38:36 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $i = 1,$B = 1
Opt("GUIOnEventMode",1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("有鼠?效?的?候如何加循?段", 367, 147)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Label1 = GUICtrlCreateLabel("", 48, 16, 60, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Button1", 48, 56, 115, 49)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

AdlibRegister("xh",6000)


While 1
  $Info = GUIGetCursorInfo($Form1)
  If Not @error Then
  If  $info[4] = $Button1 And $B = 1 Then 
   MsgBox(0,0,'鼠?在按?上')
   $B = 0
  ElseIf $info[4] <> $Button1 And $B = 0 Then
   ;MsgBox(0,0,'鼠?已离?按?')
   $B = 1
  EndIf 
    EndIf   

WEnd
Func _Exit()
Exit
EndFunc   ;==>_Exit


Func xh()
       GUICtrlSetData($Label1,$i)
       $i+= 1    
EndFunc
 楼主| 发表于 2018-7-20 08:27:40 | 显示全部楼层

感谢K大,谢谢!
发表于 2018-7-20 08:40:13 | 显示全部楼层
msgbox是阻断型函数,一旦调用,这个进程就会暂停,因此,当msgbox弹出时,label的计时一定会停止.不管怎么做
 楼主| 发表于 2018-7-20 08:41:22 | 显示全部楼层
本帖最后由 qsy666888 于 2018-7-20 08:43 编辑
tubaba 发表于 2018-7-20 08:40
msgbox是阻断型函数,一旦调用,这个进程就会暂停,因此,当msgbox弹出时,label的计时一定会停止.不管怎么做

真是你说的如此
发表于 2018-7-20 11:25:46 | 显示全部楼层
定时器了解下
 楼主| 发表于 2018-7-20 11:57:05 | 显示全部楼层

谢谢,定时器能解决这个问题,谢谢前面几位大佬
发表于 2018-7-20 12:22:22 | 显示全部楼层
确实,settimer可以做到..忘了这一点 @afan
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 06:19 , Processed in 0.083631 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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