guigetmsg

  • Ich habe ein Gui gemacht, welches ein pic (guictrlcreatepic ) enthält ... Wenn ich jetzt ne schleife mach:

    [autoit]


    $gui=guicreate('test')
    $pic=guictrlcreatepic('test.gif', 10, 10)
    guisetstate()
    while 1
    switch $msg
    case $pic
    msgbox(0, '', 'Du hast Auf das Bild geklickt')
    endswitch
    wend

    [/autoit]

    Dann wird die ganze Zeit die msgbox engezeigt (also wie wenn man immer auf das Bild drücken würd. Warum???

  • In der Hilfe steht

    Spoiler anzeigen
    [autoit]


    $msg = GUIGetMsg()
    Switch $msg ...

    [/autoit]

    Und du möchtest die MSGBOX immer haben wenn das Bild erstellt wird. ;)
    Also funktioniert dein Script. ;)

    MfG
    Der_Doc

  • Hallo Scripter192,

    probiers doch mal so,

    Spoiler anzeigen
    [autoit]

    ; *** Start added by AutoIt3Wrapper ***
    #include <GUIConstantsEx.au3>
    ; *** End added by AutoIt3Wrapper ***
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Add_Constants=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    Global $aInfo[4]
    Global $gui=guicreate('test')
    Global $pic=guictrlcreatepic('bk.gif', 10, 10)
    Global $msg
    guisetstate()

    [/autoit] [autoit][/autoit] [autoit]

    while 1
    switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $GUI_EVENT_PRIMARYDOWN
    $aInfo = GUIGetCursorInfo($Gui)
    If $aInfo[4] = $pic Then msgbox(0, '', 'Du hast Auf das Bild geklickt')
    endswitch
    wend

    [/autoit]


    oder so

    Spoiler anzeigen
    [autoit]

    ; *** Start added by AutoIt3Wrapper ***
    #include <GUIConstantsEx.au3>
    ; *** End added by AutoIt3Wrapper ***
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Add_Constants=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    Opt('GUIOnEventMode', 1)
    Opt('MUSTDECLAREVARS' ,1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $gui=guicreate('test')
    GUISetOnEvent($GUI_EVENT_CLOSE, '_exitMain')
    Global $pic=guictrlcreatepic('bk.gif', 10, 10)
    GUICtrlSetOnEvent(-1,'_picIsClicked')
    Global $msg
    guisetstate()
    while 1
    Sleep(100)
    wend

    [/autoit] [autoit][/autoit] [autoit]

    Func _exitMain()
    Exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _picIsClicked()
    msgbox(0, '', 'Du hast Auf das Bild geklickt')
    EndFunc

    [/autoit]

    wobei ich die 2. Version bevorzugen würde

    mfg (Auto)Bert

    Einmal editiert, zuletzt von AutoBert (24. April 2009 um 15:47)

    • Offizieller Beitrag

    Es funktioniert auch so:

    [autoit]


    #include <GUIConstantsEx.au3>
    $gui = GUICreate('test')
    $pic = GUICtrlCreatePic(@SystemDir & '\oobe\images\merlin.gif', 10, 10, 0, 0)
    GUISetState()
    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $pic
    MsgBox(0, '', 'Du hast Auf das Bild geklickt')
    EndSwitch
    WEnd

    [/autoit]