找回密码
 加入
搜索
查看: 6187|回复: 9

[GUI管理] GuiGetMsg(1) 返回控件ID问题 [已解决]

  [复制链接]
发表于 2010-5-26 17:26:45 | 显示全部楼层 |阅读模式
本帖最后由 republican 于 2010-8-10 09:07 编辑

代码如下:
#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Opt("ExpandVarStrings", 1) 
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, $group_1, $radio_1, $radio_2, $radio_3
        Local $radioval1, $radioval2, $msg,$Formtest,$labe1

        Opt("GUICoordMode", 1)
        $Formtest = GUICreate("Radio Box Demo", 400, 280)
        $button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
        $labe1= GUICtrlCreateList($button_1,100,70,200,1000)
        GUISetState()
        
        While 1
                $msg = GUIGetMsg(1)
                If $msg[0] <> 0 And $msg[1] = $Formtest Then ;
                        GUICtrlSetData($labe1,$msg[2])
                        Sleep(50)
                Select
                        Case $msg[1] = $Formtest
                                        Case $msg[2] = $GUI_EVENT_CLOSE
                                                MsgBox(0, "", "Dialog was closed")
                                                Exit
                                        Case $msg[2] = $GUI_EVENT_MINIMIZE
                                                MsgBox(0, "", "Dialog minimized", 2)
                                        Case $msg[2] = $GUI_EVENT_MAXIMIZE
                                                MsgBox(0, "", "Dialog restored", 2)
                                        Case $msg[2] = $button_1
                                                MsgBox(0, "Default button clicked", "Radio " & $radioval1)
                EndSelect
        EndIf
        WEnd

;~ While 1
;~                 $msg = GUIGetMsg()
;~                 GUICtrlSetData($labe1,$msg&'"  '&$button_1);&'"  '&$msg[2])
;~                 Select
;~                         Case $msg = $GUI_EVENT_CLOSE
;~                                 MsgBox(0, "", "Dialog was closed")
;~                                 Exit
;~                         Case $msg = $GUI_EVENT_MINIMIZE
;~                                 MsgBox(0, "", "Dialog minimized", 2)
;~                         Case $msg = $GUI_EVENT_MAXIMIZE
;~                                 MsgBox(0, "", "Dialog restored", 2)

;~                         Case $msg = $button_1
;~                                 MsgBox(0, "Default button clicked", "Radio " & $radioval1)

;~                         Case $msg >= $radio_1 And $msg <= $radio_3
;~                                 $radioval1 = $msg - $radio_1

;~                 EndSelect
;~         WEnd

        

EndFunc   ;==>Example
注释掉的为原来的正常代码。



3为控件ID,然而GetMsg获得却是不知道什么进制的数(窗口ID能正确获取,0X00000000,应该为没发生任何事的情况),遂请问各位,
如何能在高级模式中使代码正常运行?

PS:搜官方网站以前貌似有个Opt("GUIEventAdvancedMode", 1)参数,现在没了,不知道是不是官方放弃了支持?

本帖子中包含更多资源

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

×
发表于 2010-5-26 17:40:10 | 显示全部楼层
顶贴、回帖、拿分走人!
发表于 2010-5-26 17:46:29 | 显示全部楼层
看着有点象句柄,不过为什么为0不太清楚了
发表于 2010-5-26 20:45:52 | 显示全部楼层
顶贴、回帖、拿分、走人!url
 楼主| 发表于 2010-5-26 22:11:09 | 显示全部楼层
自己顶贴~~~
发表于 2010-5-27 10:40:25 | 显示全部楼层
楼主在研究什么呢?是想这样吗
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Opt("ExpandVarStrings", 1)
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, $group_1, $radio_1, $radio_2, $radio_3
        Local $radioval1, $radioval2, $msg, $Formtest, $labe1
        Opt("GUICoordMode", 1)
        $Formtest = GUICreate("Radio Box Demo", 400, 280)
        $button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
        $labe1 = GUICtrlCreateList($button_1, 100, 70, 200, 100)
        GUISetState()
        While 1
                $msg = GUIGetMsg(1)
                  If $msg[1] = $Formtest Then ;
            GUICtrlSetData($labe1,$msg[2])
            Sleep(50)
                        Select
                                Case $msg[0] = $GUI_EVENT_CLOSE
                                        GUICtrlSetData($labe1, $msg[2])
                                        MsgBox(0, "", "Dialog was closed")
                                        Exit
                                Case $msg[0] = $GUI_EVENT_MINIMIZE
                                        GUICtrlSetData($labe1, $msg[2])
                                        MsgBox(0, "", "Dialog minimized", 2)
                                Case $msg[0] = $GUI_EVENT_MAXIMIZE
                                        GUICtrlSetData($labe1, $msg[2])
                                        MsgBox(0, "", "Dialog restored", 2)
                                Case $msg[0] = $button_1
                                        GUICtrlSetData($labe1, $msg[2])
                                        MsgBox(0, "Default button clicked", "Radio " & $radioval1)
                        EndSelect
                EndIf
        WEnd
EndFunc   ;==>Example
 楼主| 发表于 2010-5-27 15:13:04 | 显示全部楼层
理解错误了,不好意思。
谢谢六楼。
发表于 2011-1-25 02:10:09 | 显示全部楼层
本帖最后由 papapa314 于 2011-1-25 02:12 编辑

回复 1# republican

Case $msg[2] = $GUI_EVENT_CLOSE  这个好像写错了,事件应该是Case $msg[0] = $GUI_EVENT_CLOSE

看看下面的代码是不是你所需要的?
#include <GUIConstantsEx.au3>



Opt('MustDeclareVars', 1)

Opt("ExpandVarStrings", 1) 

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, $group_1, $radio_1, $radio_2, $radio_3

        Local $radioval1, $radioval2, $msg,$Formtest,$labe1



        Opt("GUICoordMode", 1)

        $Formtest = GUICreate("Radio Box Demo", 400, 280)

        $button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)

        $labe1= GUICtrlCreateList($button_1,100,70,200,1000)

        GUISetState()




        While 1

                $msg = GUIGetMsg(1)

      

                Select

                        

                                        Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $Formtest

                                                MsgBox(0, "", "Dialog was closed")

                                                Exit

                                        Case $msg[0] = $GUI_EVENT_MINIMIZE And $msg[1] = $Formtest

                                                MsgBox(0, "", "Dialog minimized", 2)

                                        Case $msg[0] = $GUI_EVENT_MAXIMIZE And $msg[1] = $Formtest

                                                MsgBox(0, "", "Dialog restored", 2)

                                        Case $msg[0] = $button_1 And $msg[1] = $Formtest

                                                MsgBox(0, "Default button clicked", "Radio " & $radioval1)

                EndSelect

    

        WEnd
                
                EndFunc 
 楼主| 发表于 2011-1-25 08:05:13 | 显示全部楼层
回复 8# papapa314

谢谢~

那是以前写的程序用的,现在改用Windows消息来响应了。
发表于 2011-6-20 22:58:12 | 显示全部楼层
有捕获控件ID的软件吗?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-1 10:43 , Processed in 0.081413 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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