GUIGetMsg()重复怎么破?
本帖最后由 l4ever 于 2014-6-23 05:02 编辑下面是官方的例子
运行之后鼠标狂点Button1
等下弹出一大堆的msgbox
这是BUG么?
即便是弹出了msgbox,你不管他,接着点 Button1 ,然后你得关闭一大堆msgbox
后来试了试换个思路,用 GUICtrlSetOnEvent
还是官方的例子,居然还是酱紫.
autoit 版本:3.3.9.21
大家麻烦试试是不是这样的?#include <GUIConstantsEx.au3>
Example()
;-------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).
Func Example()
Local $button_1, $radio_1, $radio_3
Local $radioval1, $msg
Opt("GUICoordMode", 1)
GUICreate("Radio Box Demo", 400, 280)
; Create the controls
$button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
GUICtrlCreateGroup("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20)
GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20)
$radio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20)
; Init our vars that we will use to keep track of GUI events
$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
; Show the GUI
GUISetState()
; In this message loop we use variables to keep track of changes to the radios, another
; way would be to use GUICtrlRead() at the end to read in the state of each control
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(4096, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
MsgBox(4096, "", "Dialog minimized", 2)
Case $msg = $GUI_EVENT_MAXIMIZE
MsgBox(4096, "", "Dialog restored", 2)
Case $msg = $button_1 and $msg <> ""
$msg = ""
MsgBox(4096, "Default button clicked", "Radio " & $radioval1)
Case $msg >= $radio_1 And $msg <= $radio_3
$radioval1 = $msg - $radio_1
EndSelect
sleep(100)
WEnd
EndFunc ;==>Example
本帖最后由 shqf 于 2014-6-23 15:36 编辑
程序设计的就是点Button1,就会运行msgbox,弹出一个对话框。
你点Button1 N下,就会弹出N个窗口,只是窗口会一个一个显示出来而已。即关闭前一个后才显示下一个,总之点击事件程序是已经接收到了。
你狂点Button1,还想让程序做什么反应呢? 回复 1# l4ever
彈出前 要先把 GUI 凍結那就不會造成 一跳出問題 帮顶{:face (427):} 你弄过GUI替代 maXBOX不就完事了,msgbox会中断程序,尽量少使用把。 本帖最后由 pcbar 于 2014-6-24 14:41 编辑
#include <GUIConstantsEx.au3>
Example()
;-------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).
Func Example()
Local $button_1, $radio_1, $radio_3
Local $radioval1, $msg
Opt("GUICoordMode", 1)
GUICreate("Radio Box Demo", 400, 280)
; Create the controls
$button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
GUICtrlCreateGroup("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20)
GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20)
$radio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20)
; Init our vars that we will use to keep track of GUI events
$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
; Show the GUI
GUISetState()
; In this message loop we use variables to keep track of changes to the radios, another
; way would be to use GUICtrlRead() at the end to read in the state of each control
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(4096, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
MsgBox(4096, "", "Dialog minimized", 2)
Case $msg = $GUI_EVENT_MAXIMIZE
MsgBox(4096, "", "Dialog restored", 2)
Case $msg = $button_1
GUICtrlSetState($button_1, $gui_disable)
MsgBox(4096, "Default button clicked", "Radio " & $radioval1)
GUICtrlSetState($button_1, $gui_enable)
Case $msg >= $radio_1 And $msg <= $radio_3
$radioval1 = $msg - $radio_1
EndSelect
WEnd
EndFunc ;==>Example 这是官方的例子吗?不象啊,
官方例子不会出现sleep(100)
和Case $msg = $button_1 and $msg <> ""
$msg = ""
的低级问题的 这是官方的例子吗?不象啊,
官方例子不会出现sleep(100)
和Case $msg = $button_1 and $msg""
...
seniors 发表于 2014-6-25 19:30 http://www.autoitx.com/images/common/back.gif
确实… 这段代码蛋疼得很~ 像我这种菜中菜只有看到的份
页:
[1]