ControlGetPos Problem

  • Hallo,

    ich geb mich für heute geschlagen...
    Folgendes Problem:

    1. Meine Form hat mehrere Buttons
    2. Ich drücke die TAB Taste um zu den Buttons zu springen

    soweit ok!

    Nun ermittele ich die jeweilige ID und vergrößere den Button. Das klappt auch.

    Aber dann:

    Drücke ich den TAB erneut, dann soll der "vergrößerte Button" wieder an den Ursprungsort zurück
    und dann der nächste vergrößert werden. Das krieg ich nicht hin.

    Zum Testen einfach nur die TAB-Taste drücken

    Mein Code:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #include <WinAPI.au3>

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

    $hwndMain = GUICreate("Form1", 543, 443, 192, 124)
    $Combo1 = GUICtrlCreateCombo("Combo1", 48, 48, 145, 25)
    $Button1 = GUICtrlCreateButton("Button1", 48, 104, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Button2", 136, 104, 75, 25, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("Button3", 224, 104, 75, 25, $WS_GROUP)
    $Button4 = GUICtrlCreateButton("Button4", 312, 104, 75, 25, $WS_GROUP)
    $Button5 = GUICtrlCreateButton("Button5", 408, 104, 75, 25, $WS_GROUP)
    $Button6 = GUICtrlCreateButton("Button6", 48, 144, 75, 25, $WS_GROUP)
    $Button7 = GUICtrlCreateButton("Button7", 136, 144, 75, 25, $WS_GROUP)
    $Button8 = GUICtrlCreateButton("Button8", 224, 144, 75, 25, $WS_GROUP)
    $Button9 = GUICtrlCreateButton("Button9", 312, 144, 75, 25, $WS_GROUP)
    $Button10 = GUICtrlCreateButton("Button10", 408, 144, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    GUISetState(@SW_MAXIMIZE)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch

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

    If _IsPressed(09)Then

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

    _Buttonpos()

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

    endif
    WEnd

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

    func _Buttonpos()
    Local $pos[4]
    Local $control = ControlGetFocus($hwndMain)
    Local $hHandle = ControlGetHandle($hwndMain, "", $control); Handle des selektierten Controls holen
    Local $ICtrlId = _WinAPI_GetDlgCtrlID($hHandle); CtrlId aus dem Handle erstellen

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

    MsgBox(0, "Button-ID", $ICtrlId,1)
    $pos = ControlGetPos("", "", $ICtrlId)

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

    GUICtrlSetPos($ICtrlId, -1,-1,@DesktopWidth/2,@DesktopHeight-200); Button wird vergrößert

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

    endfunc

    [/autoit]

    Ich möchte einfach nur per TAB z.B. zum 4. Button gehen
    und der sollte dann automatisch z.B. nach 1 Sekunde vergrößert werden

    Liebe Grüße
    Ilse

    P.S. Besser wäre natürlich die Navigation mit den Pfeiltasen
    Aber das klappt nicht

    Einmal editiert, zuletzt von Ilse (24. April 2012 um 19:44)

  • Zwar ist mir der tiefere Sinn dahinter nicht klar, aber so gehts:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <Misc.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    $hwndMain = GUICreate("Form1", 543, 443, 192, 124)
    $Combo1 = GUICtrlCreateCombo("Combo1", 48, 48, 145, 25)
    $Button1 = GUICtrlCreateButton("Button1", 48, 104, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Button2", 136, 104, 75, 25, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("Button3", 224, 104, 75, 25, $WS_GROUP)
    $Button4 = GUICtrlCreateButton("Button4", 312, 104, 75, 25, $WS_GROUP)
    $Button5 = GUICtrlCreateButton("Button5", 408, 104, 75, 25, $WS_GROUP)
    $Button6 = GUICtrlCreateButton("Button6", 48, 144, 75, 25, $WS_GROUP)
    $Button7 = GUICtrlCreateButton("Button7", 136, 144, 75, 25, $WS_GROUP)
    $Button8 = GUICtrlCreateButton("Button8", 224, 144, 75, 25, $WS_GROUP)
    $Button9 = GUICtrlCreateButton("Button9", 312, 144, 75, 25, $WS_GROUP)
    $Button10 = GUICtrlCreateButton("Button10", 408, 144, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    GUISetState(@SW_MAXIMIZE)

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

    Dim $ICtrlId, $pos
    Dim $check = 0

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch

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

    If _IsPressed(09) And $check = 0 Then
    $check = 1
    ElseIf Not _IsPressed(09) And $check = 1 Then
    $check = 0
    _Buttonpos()
    EndIf
    WEnd

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

    Func _Buttonpos()
    If Not $ICtrlId = "" Then
    GUICtrlSetPos($ICtrlId, $pos[0], $pos[1], $pos[2], $pos[3])
    EndIf

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

    Local $control = ControlGetFocus($hwndMain)
    Local $hHandle = ControlGetHandle($hwndMain, "", $control); Handle des selektierten Controls holen
    $ICtrlId = _WinAPI_GetDlgCtrlID($hHandle); CtrlId aus dem Handle erstellen

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

    $pos = ControlGetPos("", "", $ICtrlId)

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

    GUICtrlSetPos($ICtrlId, -1, -1, @DesktopWidth / 2, @DesktopHeight - 200); Button wird vergrößert

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

    EndFunc ;==>_Buttonpos

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Hallo Chip,

    merci für die Hilfe.

    Noch Frage: (Verzeih mir...)
    Die Pfeiltasten: Vor zurück...
    Muß man dann jede ID abfragen?

    Der tiefere Sinn?
    Ich mach das für einen älteren Bekannten der so seine Klick-Probleme hat.

    Mit den Pfeiltasten, das wäre Super...
    Habe mit (27, 28...) probiert, geht leider nicht!
    Mit der TAB Taste kommt er nur vorwärts


    ;) Liebe Grüße
    Ilse

  • So?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <Misc.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    HotKeySet("{LEFT}", "links")
    HotKeySet("{RIGHT}", "rechts")

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

    Dim $buttons[10]
    Dim $buttinid = 0
    Dim $pos
    Dim $altbuttonhandler = 0

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

    $hwndMain = GUICreate("Form1", 543, 443, 192, 124)
    $Combo1 = GUICtrlCreateCombo("Combo1", 48, 48, 145, 25)
    $buttons[0] = GUICtrlCreateButton("Button1", 48, 104, 75, 25, $WS_GROUP)
    $buttons[1] = GUICtrlCreateButton("Button2", 136, 104, 75, 25, $WS_GROUP)
    $buttons[2] = GUICtrlCreateButton("Button3", 224, 104, 75, 25, $WS_GROUP)
    $buttons[3] = GUICtrlCreateButton("Button4", 312, 104, 75, 25, $WS_GROUP)
    $buttons[4] = GUICtrlCreateButton("Button5", 408, 104, 75, 25, $WS_GROUP)
    $buttons[5] = GUICtrlCreateButton("Button6", 48, 144, 75, 25, $WS_GROUP)
    $buttons[6] = GUICtrlCreateButton("Button7", 136, 144, 75, 25, $WS_GROUP)
    $buttons[7] = GUICtrlCreateButton("Button8", 224, 144, 75, 25, $WS_GROUP)
    $buttons[8] = GUICtrlCreateButton("Button9", 312, 144, 75, 25, $WS_GROUP)
    $buttons[9] = GUICtrlCreateButton("Button10", 408, 144, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    GUISetState(@SW_MAXIMIZE)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch

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

    WEnd

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

    Func _Buttonpos($buttinid)
    If Not $altbuttonhandler = "" Then
    GUICtrlSetPos($altbuttonhandler, $pos[0], $pos[1], $pos[2], $pos[3])
    EndIf

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

    $altbuttonhandler = $buttons[$buttinid]
    $pos = ControlGetPos("", "", $buttons[$buttinid])

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

    GUICtrlSetPos($buttons[$buttinid], -1, -1, @DesktopWidth / 2, @DesktopHeight - 200); Button wird vergrößert

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

    EndFunc ;==>_Buttonpos

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

    Func links()
    If Not $buttinid = 0 Then
    $buttinid = $buttinid - 1
    _Buttonpos($buttinid)
    EndIf
    EndFunc ;==>links

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

    Func rechts()
    If $buttinid < 9 Then
    $buttinid = $buttinid + 1
    _Buttonpos($buttinid)
    ConsoleWrite($buttinid)
    EndIf
    EndFunc ;==>rechts

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.