Pic per Pfeiltaste verschieben

  • Ich habe einen Script:

    Spoiler anzeigen
    [autoit]


    #include
    #include
    #include

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

    Opt("GuiOnEventMode", 1)
    $gui = GUICreate("Autoit-Mapper", 500, 500, -1, -1, $WS_POPUP)
    $map = GUICtrlCreatePic(@DesktopDir & "\haus.jpg", 1, 1, 500, 500, -1)
    GUICtrlSetState(-1, $Gui_Disable)
    $punkt = GUICtrlCreatePic(@DesktopDir & "\punkt1.gif", 500 / 2 - 15, 500 / 2 - 15, 30, 30)
    GUICtrlSetOnEvent(-1, "_DragIt")
    GUISetState()

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

    While 1
    Sleep(100)
    WEnd

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

    Func _DragIt()
    Local $Pos_C, $Pos_M, $Pos_M2, $Opt_old
    Local $dll = DllOpen("user32.dll")
    $Opt_old = Opt('MouseCoordMode', 0)
    $Pos_C = ControlGetPos($gui, "", $punkt)
    $Pos_M = MouseGetPos()
    $y_Offset = $Pos_M[1] - $Pos_C[1]
    $x_Offset = $Pos_M[0] - $Pos_C[0]
    While _IsPressed('01', $dll)
    $Pos_M = MouseGetPos()
    If $Pos_M <> $Pos_M2 Then
    GUICtrlSetPos($punkt, $Pos_M[0] - $x_Offset, $Pos_M[1] - $y_Offset)
    EndIf
    $Pos_M = $Pos_M2
    Sleep(50)
    WEnd
    DllClose($dll)
    Opt('MouseCoordMode', $Opt_old)
    EndFunc ;==>_DragIt

    [/autoit]

    Anstadt auf das Bild zu klicken um es zu verschieben, will das Bild per Pfeiltasten steuern.
    (Also Obere Pfeiltaste soll das Bild nach oben gehen.)


    Jemand ne Idee ?


    Edit bernd670: Quellcode formatiert und Spoiler-Tags gesetzt (ist das so schwer ;) )
    Ja ^^ der Code ging nicht nacheinander sondern alle 30+ Reihen hintereinander (d0npers)

    16 Mal editiert, zuletzt von d0npers (17. Mai 2009 um 13:48)

    • Offizieller Beitrag

    Schau dir mal in der Hilfe das Beispiel 2 von GUICtrlCreatePic an, Da findest du alles was du brauchst .Einfach WinMove gegen ControlMove austauschen .