Button Funktion..

  • #NoTrayIcon
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Icon=little iconpack\icon.ico
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include<WindowsConstants.au3>
    #include<Misc.au3>
    $hGui = GUICreate("", 400, 400, default, default, $WS_POPUP)
    $bhandle = GUICtrlCreateButton("Button :>", 30, 30, 60, 55)
    GUISetBkColor(0x00FF00)
    GUISetState()
    while 1
    $mPos = GUIGetCursorInfo()
    if IsArray($mPos) And _IsPressed(01) Then
    $Fenster_Position = WinGetPos($hGui) ; Fensterposition herrausfinden
    $Maus_Position = MouseGetPos() ; Mausposition herrausfinden
    $Maus_Position_Vorher = MouseGetPos() ; "
    While _IsPressed(01) = 1
    $Maus_Position = MouseGetPos() ; Die neue Mausposition herausfinden
    WinMove($hGui, "", $Maus_Position[0] - $Maus_Position_Vorher[0] + $Fenster_Position[0], $Maus_Position[1] - $Maus_Position_Vorher[1] + $Fenster_Position[1])
    ; Keine ahnung warum, aber es geht^^
    WEnd
    EndIf
    if _IsPressed("1B") Then exit ; ESC
    WEnd


    While 2
    $msg = GUIGetMsg()
    Switch $msg
    Case -3
    Exit
    Case $bhandle
    _llo()
    EndSwitch
    WEnd

    func _llo()
    msgbox(0, "", "")
    EndFunc


    Warum Funktioniert das mit dem button nicht? :(

    Einmal editiert, zuletzt von Litom2 (29. August 2012 um 18:55)

  • Oha, dir fehtl aber wissen :/
    naja ok:
    Du hast die Überprüfung des Button ja in der zweiten Schleife. Diese Schleife wird aber nirgens aufgerufen, sprich sie wird nie ausgeführt.
    Am besten du steckst die Überprüfung des Buttons in die erste While-Schleife, dann gehts garantiert.

    mfg
    Hauke

    ps.: Damit der Code einfacher zu lesen ist, gibts im Editor einen Button für AutoIt-Quellcode ( zweite Zeile der Bedienelemente ganz rechts )

    • Offizieller Beitrag

    Ganz einfach, deine 2. While Wend Schleife wird nie ausgeführt.

  • Hi, der While-Block beginnt mit While und endet mit WEnd- Die Abbruchbedingung fuer eine Schleife wird gleich neben den Schleifenstart geschrieben, also "While 1". Der Einser steht hier NICHT fuer eine Zahl (1,2 oder 3) sondern fuer True ! ;)

    Spoiler anzeigen
    [autoit]


    #NoTrayIcon
    #region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Icon=little iconpack\icon.ico
    #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include<WindowsConstants.au3>
    #include<Misc.au3>

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

    $hGui = GUICreate("", 400, 400, Default, Default, $WS_POPUP)
    $bhandle = GUICtrlCreateButton("Button :>", 30, 30, 60, 55)
    GUISetBkColor(0x00FF00)
    GUISetState()
    While 1

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

    $msg = GUIGetMsg()
    Switch $msg
    Case -3
    ExitLoop
    Case $bhandle
    _llo()
    EndSwitch

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

    $mPos = GUIGetCursorInfo()
    If IsArray($mPos) And _IsPressed(01) Then
    $Fenster_Position = WinGetPos($hGui) ; Fensterposition herrausfinden
    $Maus_Position = MouseGetPos() ; Mausposition herrausfinden
    $Maus_Position_Vorher = MouseGetPos() ; "
    While _IsPressed(01) = 1
    $Maus_Position = MouseGetPos() ; Die neue Mausposition herausfinden
    WinMove($hGui, "", $Maus_Position[0] - $Maus_Position_Vorher[0] + $Fenster_Position[0], $Maus_Position[1] - $Maus_Position_Vorher[1] + $Fenster_Position[1])
    ; Keine ahnung warum, aber es geht^^
    WEnd
    EndIf
    If _IsPressed("1B") Then Exit ; ESC
    WEnd

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

    Func _llo()
    MsgBox(0, "", "Bitteschoen !")
    EndFunc ;==>_llo

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

    #comments-start
    While 2
    $msg = GUIGetMsg()
    Switch $msg
    Case -3
    ExitLoop
    Case $bhandle
    _llo()
    EndSwitch
    WEnd

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

    #comments-end
    ; Ende

    [/autoit]

    DA WAR ICH WOHL SCHNELLER !! ;)