position eines elements bestimmen

  • omg!!^^
    Wie bestimmt man nochmal die Position eines Elements inerhalb des scriptes?

  • ich will jetzt mit den pfeiltasten den button bewegen,
    also einfach mit hotkeyset und guictrlsetpos.
    Aber wie finde ich die position des buttons raus?
    (die brauche ich doch um ihn zu bewegen!)


    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 625, 445, 192, 124)
    $Button1 = GUICtrlCreateButton("test1", 128, 112, 73, 81, $WS_GROUP)

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

    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

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

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


    EndSwitch
    WEnd

    [/autoit]
  • das hab ich mir auch schon gedacht,
    aber ich dachte man kann damit nur positionen von externen sachen bestimmen
    also z.B notepad und nciht ein button

    danke

  • Wie mein Mathelehrer immer zu sagen pflegt: "Das ist grober Unfug!"...

    [autoit]

    #include <Array.au3>

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

    $hWnd = GUICreate("")
    $cButton = GUICtrlCreateButton("Test", 150, 185, 100, 25)
    GUISetState()

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

    $aPos = ControlGetPos($hWnd, "", $cButton)
    _ArrayDisplay($aPos)

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

    While GUIGetMsg() <> -3
    WEnd

    [/autoit]
  • Natürlich kann man beide benutzen! Seine GUI und eine andere.

    [autoit]

    ControlGetPos ( "title", "text", controlID )
    ;; "titel" = Name deiner GUI (Vllt in einer Variable?)
    ;; "text" = Kannst du eig. leer lassen
    ;; "ControlID" = ID des Controls von dem du die Position bekommen möchtest, ganz einfach durch Variablen beim erstellen zu bekommen
    $hControlID=GuiCtrlCreateButton()

    [/autoit]

    //Edit: Da name22 schon eine Grundlage gegeben hat hab ich gleich mal was kleines gebastelt.

    [autoit]

    #include <Misc.au3>

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

    Global $iMoveSpeed = 1

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

    $hWnd = GUICreate("")
    $cButton = GUICtrlCreateButton("Test", 150, 185, 100, 25)
    GUISetState()

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

    $aPos = ControlGetPos($hWnd, "", $cButton)

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

    While GUIGetMsg() <> -3
    Sleep(20)
    $aPos = ControlGetPos($hWnd, "", $cButton)

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

    If _IsPressed(25) Then GUICtrlSetPos($cButton, $aPos[0] - $iMoveSpeed, $aPos[1])

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

    If _IsPressed(26) Then GUICtrlSetPos($cButton, $aPos[0], $aPos[1] - $iMoveSpeed)

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

    If _IsPressed(27) Then GUICtrlSetPos($cButton, $aPos[0] + $iMoveSpeed, $aPos[1])

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

    If _IsPressed(28) Then GUICtrlSetPos($cButton, $aPos[0], $aPos[1] + $iMoveSpeed)

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

    WEnd

    [/autoit]

    mfg BB

    "IF YOU'RE GOING TO KILL IT
    OPEN SOURCE IT!"

    by Phillip Torrone

    Zitat von Shoutbox

    [Heute, 11:16] Andy: ....böseböseböseböse....da erinnere ich mich daran, dass man den Puschelschwanz eines KaRnickels auch "Blume" nennt....ob da eins zum anderen passt? :rofl: :rofl: :rofl: :rofl:

    https://autoit.de/index.php?page…leIt#post251138

    Neon Snake