_WinAPI_DrawLine, mit Pfeiltasten Rechteck bewegen

  • Hallo,

    ich versuche für mein Projekt ein Rechteck mit den Pfeiltasten bewegen zu lassen, leider schaff ich des nicht..ich hoffe auf Eure Hilfe!

    Danke!

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #include <GDIPlus.au3>
    #include <ScreenCapture.au3>
    #include <WinAPI.au3>
    $dll = DllOpen("user32.dll")
    Opt("GUIOnEventMode", 1)
    #region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\besitzer\desktop\au3\lupe.kxf
    $Form1 = GUICreate("Form1", 422, 255, 286, 196)
    GUISetState($WS_EX_TOPMOST)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
    GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
    GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
    $Slider1 = GUICtrlCreateSlider(32, 56, 150, 45)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetLimit($Slider1, 100, 0)
    GUICtrlSetData($Slider1, 50)
    ;GUICtrlSetOnEvent(-1, "Slider1Change")
    $Slider2 = GUICtrlCreateSlider(32, 152, 150, 45)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetLimit($Slider2, 100, 0)
    GUICtrlSetData($Slider2, 50)
    ;GUICtrlSetOnEvent(-1, "Slider2Change")
    $Input1 = GUICtrlCreateInput("", 224, 32, 150, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
    GUICtrlSetOnEvent(-1, "Input1Change")
    $Label1 = GUICtrlCreateLabel("Koordinaten:", 224, 15, 64, 17)
    GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
    GUICtrlSetOnEvent(-1, "Label1Click")
    $Label2 = GUICtrlCreateLabel("x - Achse", 40, 40, 48, 17)
    GUICtrlSetOnEvent(-1, "Label2Click")
    $Label3 = GUICtrlCreateLabel("y - Achse", 40, 136, 48, 17)
    GUICtrlSetOnEvent(-1, "Label3Click")
    ;$Label4 = GUICtrlCreateLabel("", 224, 64, 150, 150)
    ;GUICtrlSetOnEvent(-1, "Label4Click")
    #endregion ### END Koda GUI section ###
    ;$hDesktop = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $GUI_BKCOLOR_TRANSPARENT))
    Dim $iX1o, $iY1o, $iX2o, $iY2o, $iX1u, $iY1u, $iX2u, $iY2u, $iX1l, $iY1l, $iX2l, $iY2l, $iX1r, $iY1r, $iX2r, $iY2r

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

    Local $hDC, $hPen, $obj_orig
    $width = 1
    $color = 0xFF
    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $width, $color)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
    Dim $coordLR, $coordHR, $countLR, $countHR, $ok
    $dist = 5
    $Scale = 30
    $sl1 = 50
    $sl2 = 50
    Dim $Lay[$Scale + 1][$Scale + 1]
    Dim $PosOld[2]
    For $x = 1 To $Scale
    For $y = 1 To $Scale
    $Lay[$x][$y] = GUICtrlCreateLabel("", 224 + $x * 5, 64 + $y * 5, 5, 5, $SS_RIGHT);, BitOR($SS_BLACKRECT, $SS_WHITERECT)) entweder schwarz oder weiss
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT);
    Next
    Next
    GUISetState(@SW_SHOW)
    HotKeySet("{ESC}", "_Exit")
    ;Start GUI Schleife
    While 1
    $Pos = MouseGetPos()
    For $x = 1 To $Scale
    For $y = 1 To $Scale
    $Pix = PixelGetColor(($Pos[0] + $coordLR) + $x - ($Scale / 2), ($Pos[1] + $coordHR) + $y - ($Scale / 2))
    GUICtrlSetBkColor($Lay[$x][$y], $Pix)
    Next
    Next
    ;wenn Pfeiltasten gedrückt
    If _IsPressed('25', $dll) Then ;links gedrückt
    $countLR = $countLR + (-1)
    $coordLR = $coordLR - $dist
    $sl1 = $sl1 - 10
    $iX1o = $iX1o - $dist
    $iY1o = $iY1o
    $iX2o = $iX2o - $dist
    $iY2o = $iY2o
    $iX1u = $iX1u - $dist
    $iY1u = $iY1u
    $iX2u = $iX2u - $dist
    $iY2u = $iY2u
    $iX1l = $iX1l - $dist
    $iY1l = $iY1l
    $iX2l = $iX2l - $dist
    $iY2l = $iY2l
    $iX1r = $iX1r - $dist
    $iY1r = $iY1r
    $iX2r = $iX2r - $dist
    $iY2r = $iY2r
    GUICtrlSetData($Slider1, $sl1)
    ElseIf _IsPressed('27', $dll) Then ;rechts gedrückt
    $countLR = $countLR + 1
    $coordLR = $coordLR + $dist
    $sl1 = $sl1 + 10
    ;_WinAPI_DrawLine($hDC, $iX1, $iY1, $iX2, $iY2)
    ;$iX1 X Koordinate des Startpunkts der Linie.
    ;$iY1 Y Koordinate des Startpunkts der Linie.
    ;$iX2 X Koordinate des Endpunkts der Linie.
    ;$iY2 Y Koordinate des Endpunkts der Linie.
    $iX1o = $iX1o + $dist
    $iY1o = $iY1o
    $iX2o = $iX2o + $dist
    $iY2o = $iY2o
    $iX1u = $iX1u + $dist
    $iY1u = $iY1u
    $iX2u = $iX2u + $dist
    $iY2u = $iY2u
    $iX1l = $iX1l + $dist
    $iY1l = $iY1l
    $iX2l = $iX2l + $dist
    $iY2l = $iY2l
    $iX1r = $iX1r + $dist
    $iY1r = $iY1r
    $iX2r = $iX2r + $dist
    $iY2r = $iY2r
    GUICtrlSetData($Slider1, $sl1)
    ElseIf _IsPressed('26', $dll) Then ;hoch gedrückt
    $countHR = $countHR + (-1)
    $coordHR = $coordHR - $dist
    $sl2 = $sl2 - 10
    $iX1o = $iX1o - $dist
    $iY1o = $iY1o
    $iX2o = $iX2o - $dist
    $iY2o = $iY2o
    $iX1u = $iX1u - $dist
    $iY1u = $iY1u
    $iX2u = $iX2u - $dist
    $iY2u = $iY2u
    $iX1l = $iX1l - $dist
    $iY1l = $iY1l
    $iX2l = $iX2l - $dist
    $iY2l = $iY2l
    $iX1r = $iX1r - $dist
    $iY1r = $iY1r
    $iX2r = $iX2r - $dist
    $iY2r = $iY2r
    GUICtrlSetData($Slider2, $sl2)
    ElseIf _IsPressed('28', $dll) Then ;runter gedrückt
    $countHR = $countHR + 1
    $coordHR = $coordHR + $dist
    $sl2 = $sl2 + 10
    $iX1o = $iX1o + $dist
    $iY1o = $iY1o
    $iX2o = $iX2o + $dist
    $iY2o = $iY2o
    $iX1u = $iX1u + $dist
    $iY1u = $iY1u
    $iX2u = $iX2u + $dist
    $iY2u = $iY2u
    $iX1l = $iX1l + $dist
    $iY1l = $iY1l
    $iX2l = $iX2l + $dist
    $iY2l = $iY2l
    $iX1r = $iX1r + $dist
    $iY1r = $iY1r
    $iX2r = $iX2r + $dist
    $iY2r = $iY2r
    GUICtrlSetData($Slider2, $sl2)
    EndIf
    ;wenn Mausbewegung
    If $Pos[0] <> $PosOld[0] Or $Pos[1] <> $PosOld[1] Then
    $coordHR = 0
    $coordLR = 0
    $countHR = 0
    $countLR = 0
    $PosOld = $Pos
    GUICtrlSetData($Slider1, 50)
    GUICtrlSetData($Slider2, 50)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    EndIf
    ;_WinAPI_DrawLine($hDC, $iX1, $iY1, $iX2, $iY2)
    ;$iX1 X Koordinate des Startpunkts der Linie.
    ;$iY1 Y Koordinate des Startpunkts der Linie.
    ;$iX2 X Koordinate des Endpunkts der Linie.
    ;$iY2 Y Koordinate des Endpunkts der Linie.
    _WinAPI_DrawLine($hDC, $Pos[0] - $iX1o , $Pos[1] - $iY1o, $Pos[0] + $iX2o, $Pos[1] - $iY2o) ; oben
    _WinAPI_DrawLine($hDC, $Pos[0] - $iX1u , $Pos[1] + $iY1u, $Pos[0] + $iX2u, $Pos[1] + $iY2u) ; untel
    _WinAPI_DrawLine($hDC, $Pos[0] + $iX1r , $Pos[1] - $iY1r, $Pos[0] + $iX2r, $Pos[1] + $iY2r) ; rechts
    _WinAPI_DrawLine($hDC, $Pos[0] - $iX1l , $Pos[1] - $iY1l, $Pos[0] - $iX2l, $Pos[1] + $iY2l) ; links

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

    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - 15 , $Pos[1] - 15, $Pos[0] + 16, $Pos[1] - 15) ; oben
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - 15 , $Pos[1] + 16, $Pos[0] + 16, $Pos[1] + 16) ; untel
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] + 16 , $Pos[1] - 15, $Pos[0] + 16, $Pos[1] + 16) ; rechts
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - 15 , $Pos[1] - 15, $Pos[0] - 15, $Pos[1] + 16) ; links

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

    ToolTip($countLR & ', ' & $countHR)
    GUICtrlSetData($Input1, 'Maus: x=' & $Pos[0] & ', y=' & $Pos[1]); & ' Bild: x=' & $Pos[0] + ($Scale / 2) & ', y=' & $Pos[1] + ($Scale / 2))
    Sleep(100)
    WEnd

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

    Func Form1Close()
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
    Exit
    EndFunc ;==>Form1Close
    Func Form1Maximize()
    EndFunc ;==>Form1Maximize
    Func Form1Minimize()
    EndFunc ;==>Form1Minimize
    Func Form1Restore()
    EndFunc ;==>Form1Restore
    Func Input1Change()
    EndFunc ;==>Input1Change
    Func Label1Click()
    EndFunc ;==>Label1Click
    Func Label2Click()
    EndFunc ;==>Label2Click
    Func Label3Click()
    EndFunc ;==>Label3Click
    Func Label4Click()
    EndFunc ;==>Label4Click
    Func Slider1Change()
    EndFunc ;==>Slider1Change
    Func Slider2Change()
    EndFunc ;==>Slider2Change
    ;~ Func Auswahl()
    ;~ ;Auswahlrechteck zeichnen
    ;~ ; X des Startpunkts der Linie./Y des Startpunkts der Linie./X des Endpunkts der Linie./Y des Endpunkts der Linie.
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - 15 , $Pos[1] - 15, $Pos[0] + 16, $Pos[1] - 15) ; oben
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - 15 , $Pos[1] + 16, $Pos[0] + 16, $Pos[1] + 16) ; untel
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] + 16 , $Pos[1] - 15, $Pos[0] + 16, $Pos[1] + 16) ; rechts
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - 15 , $Pos[1] - 15, $Pos[0] - 15, $Pos[1] + 16) ; links
    ;~ EndFunc
    Func _Exit()
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
    Exit
    EndFunc ;==>_Exit

    [/autoit]
  • Hallo Morrison,

    [OT]ja jetzt sehe ich es auch dass es eine Lupenfunktion ist, aber warum du nicht den Vorschlag [ offen ] Lupe geht nicht! Fenster nicht transparent? von ohforf nimmst hat mich etwas gewundert. Daraufhin Tante Google gefragt und siehe da du fährst 2 gleisig, na ja nicht verboten. Dass es ein nützliches Tool bei den Vorarbeiten zum Boten ist auch nicht. Das du das SKript komplett als eigenes Machwerk ausgibst ist unschön, denn da hat dir ein kleiner Zauberlehrling ein bischen geholfen.
    [/OT]
    ich weiss das funkey einen ScreenShot 'er gebastelt hat, vielleicht kannst du dir dort ja etwas abschauen,

    mfg autoBert

  • Hi,

    OK, das mit dem Rechteck habbich, jetzt muss ich des Fenster updaten damit ich nicht des alte Rechteck immer seh, wie bewerkstellige ich des? "Edit": Des hab ich jetzt mit

    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    gelöst!! Aber jetzt seh ich des Rechteck in der Vergrösserung nicht mehr..mpf!


    Und auc, wie grenze ich die Bewegungsgrenze mit den Slidern ein? Z.B., das ich 20 Steps auf dem Slider hab und sich dann des Rechteck nicht über die Grenzen hinaus bewegt?!

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #include <GDIPlus.au3>
    #include <ScreenCapture.au3>
    #include <WinAPI.au3>
    Opt("GUIOnEventMode", 1)
    GUISetState(@SW_SHOW)
    HotKeySet("{ESC}", "_Exit")
    #region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\besitzer\desktop\au3\lupe.kxf
    $Form1 = GUICreate("Form1", 422, 255, 286, 196)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
    GUISetState($WS_EX_TOPMOST)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $Slider1 = GUICtrlCreateSlider(32, 56, 150, 45)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetLimit($Slider1, 100, 0)
    GUICtrlSetData($Slider1, 50)
    $Slider2 = GUICtrlCreateSlider(32, 152, 150, 45)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetLimit($Slider2, 100, 0)
    GUICtrlSetData($Slider2, 50)
    $Input1 = GUICtrlCreateInput("", 224, 32, 150, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
    $Label1 = GUICtrlCreateLabel("Koordinaten:", 224, 15, 64, 17)
    GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("x - Achse", 40, 40, 48, 17)
    $Label3 = GUICtrlCreateLabel("y - Achse", 40, 136, 48, 17)
    #endregion ### END Koda GUI section ###
    Dim $iYo, $iXo, $iXu, $iYu, $iXl, $iYl, $iXr, $iYr
    Local $hDC, $hPen, $obj_orig
    Dim $coordLR, $coordHR, $countLR, $countHR, $ok
    Dim $PosOld[2]
    $width = 1
    $color = 0xFF
    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $width, $color)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
    $dist = 5
    $Scale = 30
    $sl1 = 50
    $sl2 = 50
    $dll = DllOpen("user32.dll")
    Dim $Lay[$Scale + 1][$Scale + 1]
    For $x = 1 To $Scale
    For $y = 1 To $Scale
    $Lay[$x][$y] = GUICtrlCreateLabel("", 224 + $x * 5, 64 + $y * 5, 5, 5, $SS_RIGHT);, BitOR($SS_BLACKRECT, $SS_WHITERECT)) entweder schwarz oder weiss
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT);
    Next
    Next

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

    ;Start GUI Schleife
    While 1
    $Pos = MouseGetPos()
    For $x = 1 To $Scale
    For $y = 1 To $Scale
    $Pix = PixelGetColor(($Pos[0] + $coordLR) + $x - ($Scale / 2), ($Pos[1] + $coordHR) + $y - ($Scale / 2))
    GUICtrlSetBkColor($Lay[$x][$y], $Pix)
    Next
    Next
    ;wenn Pfeiltasten gedrückt
    If _IsPressed('25', $dll) Then ;links gedrückt
    $countLR = $countLR + (-1)
    $coordLR = $coordLR - $dist
    $sl1 = $sl1 - 10
    $iXo = $iXo - $dist
    $iXu = $iXu - $dist
    $iXl = $iXl - $dist
    $iXr = $iXr - $dist
    GUICtrlSetData($Slider1, $sl1)
    _WinAPI_UpdateWindow($hDC)
    ElseIf _IsPressed('27', $dll) Then ;rechts gedrückt
    $countLR = $countLR + 1
    $coordLR = $coordLR + $dist
    $sl1 = $sl1 + 10
    $iXo = $iXo + $dist
    $iXu = $iXu + $dist
    $iXl = $iXl + $dist
    $iXr = $iXr + $dist
    GUICtrlSetData($Slider1, $sl1)
    _WinAPI_UpdateWindow($hDC)
    ElseIf _IsPressed('26', $dll) Then ;hoch gedrückt
    $countHR = $countHR + (-1)
    $coordHR = $coordHR - $dist
    $sl2 = $sl2 - 10
    $iYo = $iYo - $dist
    $iYu = $iYu - $dist
    $iYl = $iYl - $dist
    $iYr = $iYr - $dist
    GUICtrlSetData($Slider2, $sl2)
    _WinAPI_UpdateWindow($hDC)
    ElseIf _IsPressed('28', $dll) Then ;runter gedrückt
    $countHR = $countHR + 1
    $coordHR = $coordHR + $dist
    $sl2 = $sl2 + 10
    $iYo = $iYo + $dist
    $iYu = $iYu + $dist
    $iYl = $iYl + $dist
    $iYr = $iYr + $dist
    GUICtrlSetData($Slider2, $sl2)
    _WinAPI_UpdateWindow($hDC)
    EndIf
    _WinAPI_UpdateWindow($hDC)
    ;wenn Mausbewegung
    If $Pos[0] <> $PosOld[0] Or $Pos[1] <> $PosOld[1] Then
    $coordHR = 0
    $coordLR = 0
    $countHR = 0
    $countLR = 0
    $iYo = 0
    $iYu = 0
    $iYl = 0
    $iYr = 0
    $iXo = 0
    $iXu = 0
    $iXl = 0
    $iXr = 0
    $PosOld = $Pos
    GUICtrlSetData($Slider1, 50)
    GUICtrlSetData($Slider2, 50)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    EndIf
    ;_WinAPI_DrawLine($hDC, $iX1, $iY1, $iX2, $iY2)
    ;$iX1 X Koordinate des Startpunkts der Linie.
    ;$iY1 Y Koordinate des Startpunkts der Linie.
    ;$iX2 X Koordinate des Endpunkts der Linie.
    ;$iY2 Y Koordinate des Endpunkts der Linie.
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - $iX1o, $Pos[1] - $iY1o, $Pos[0] + $iX2o, $Pos[1] - $iY2o) ; oben
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - $iX1u, $Pos[1] + $iY1u, $Pos[0] + $iX2u, $Pos[1] + $iY2u) ; untel
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] + $iX1r, $Pos[1] - $iY1r, $Pos[0] + $iX2r, $Pos[1] + $iY2r) ; rechts
    ;~ _WinAPI_DrawLine($hDC, $Pos[0] - $iX1l, $Pos[1] - $iY1l, $Pos[0] - $iX2l, $Pos[1] + $iY2l) ; links
    _WinAPI_DrawLine($hDC, ($Pos[0] - 15) + $iXo, ($Pos[1] - 15) + $iYo, ($Pos[0] + 16) + $iXo, ($Pos[1] - 15) + $iYo) ; oben
    _WinAPI_DrawLine($hDC, ($Pos[0] - 15) + $iXu, ($Pos[1] + 16) + $iYu, ($Pos[0] + 16) + $iXu, ($Pos[1] + 16) + $iYu) ; untel
    _WinAPI_DrawLine($hDC, ($Pos[0] + 16) + $iXl, ($Pos[1] - 15) + $iYr, ($Pos[0] + 16) + $iXl, ($Pos[1] + 16) + $iYr) ; rechts
    _WinAPI_DrawLine($hDC, ($Pos[0] - 15) + $iXr, ($Pos[1] - 15) + $iYl, ($Pos[0] - 15) + $iXr, ($Pos[1] + 16) + $iYl) ; links
    ;~ _WinAPI_DrawLine($hDC, ($Pos[0] - 15), ($Pos[1] - 15), ($Pos[0] + 16), ($Pos[1] - 15)) ; oben
    ;~ _WinAPI_DrawLine($hDC, ($Pos[0] - 15), ($Pos[1] + 16), ($Pos[0] + 16), ($Pos[1] + 16)) ; untel
    ;~ _WinAPI_DrawLine($hDC, ($Pos[0] + 16), ($Pos[1] - 15), ($Pos[0] + 16), ($Pos[1] + 16)) ; rechts
    ;~ _WinAPI_DrawLine($hDC, ($Pos[0] - 15), ($Pos[1] - 15), ($Pos[0] - 15), ($Pos[1] + 16)) ; links

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

    ToolTip($countLR & ', ' & $countHR)
    GUICtrlSetData($Input1, 'Maus: x=' & $Pos[0] & ', y=' & $Pos[1]); & ' Bild: x=' & $Pos[0] + ($Scale / 2) & ', y=' & $Pos[1] + ($Scale / 2))
    Sleep(100)
    WEnd

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

    Func Form1Close()
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
    Exit
    EndFunc ;==>Form1Close
    Func _Exit()
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Einmal editiert, zuletzt von Morrison (17. Februar 2011 um 22:24)

  • Hi,

    habs soweit hinbekommen!

    Bin jetzt dabei Controls zum Verändern des Zoomfaktors und des Auswahlrechtecks einzubinden.
    Ich bräuchte jetzt noch Hilfe beim erstellen einer neuen GUI die in der Vergrösserung und im Auswahlrechteck zu sehen ist und die sich per INPUT-Feld verändern lässt!

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <EditConstants.au3>
    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <Misc.au3>
    #include <GDIPlus.au3>
    #include <ScreenCapture.au3>
    Opt("GUIOnEventMode", 1)
    GUISetState(@SW_SHOW)
    HotKeySet("{ESC}", "Beenden")
    ;declare
    $Scale = 10
    $sl1 = 100
    $sl2 = 100
    $SlScale = 100
    $SlScaleMin = -10
    $SlScaleMax = 10
    $dll = DllOpen("user32.dll")
    $dist = 100
    Dim $Pos
    Dim $PosOld[2]
    Local $hGUI, $hChild, $hWnd_Desktop
    Local $hDC_Dest, $hDC_Source
    Local $iX, $iY, $iW, $iH
    Local $countLR, $countHR, $coordLR, $coordHR, $iXo, $iYo
    $Pos = MouseGetPos()
    ;GUI
    $hGUI = GUICreate("Main", 200, 400, 0, 0, Default, $WS_EX_TOPMOST)
    $Slider1 = GUICtrlCreateSlider(20, 222, 160, 45)
    $Slider2 = GUICtrlCreateSlider(20, 285, 160, 45)
    $Input1 = GUICtrlCreateInput("", 8, 335, 184, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
    $Input2 = GUICtrlCreateInput("", 8, 355, 184, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
    $Input3 = GUICtrlCreateInput("", 8, 375, 184, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
    $Label1 = GUICtrlCreateLabel("Koordinaten:", 5, 318, 64, 17)
    $Label2 = GUICtrlCreateLabel("x - Achse", 19, 205, 48, 17)
    $Label3 = GUICtrlCreateLabel("y - Achse", 19, 265, 48, 17)
    GUISetState(@SW_SHOW, $hGUI)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Beenden")
    GUICtrlSetState($Slider1, $GUI_DISABLE)
    GUICtrlSetLimit($Slider1, 200, 0)
    GUICtrlSetData($Slider1, 100)
    GUICtrlSetState($Slider2, $GUI_DISABLE)
    GUICtrlSetLimit($Slider2, 200, 0)
    GUICtrlSetData($Slider2, 100)
    GUICtrlSetFont($Label1, 8, 400, 4, "MS Sans Serif")
    $hBorder = GUICreate("", ($dist / 2), ($dist / 2), $Pos[0] + ($dist / 8), $Pos[1] + ($dist / 8), $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_STATICEDGE), $hGUI)
    GUICtrlSetBkColor(GUICtrlCreateLabel("", 0, 0, 50, 50), 0xFF0000)
    GUICtrlSetBkColor(GUICtrlCreateLabel("", 2, 2, 46, 46), 0xABCDEF)
    GUISetState()
    ;ENDE GUI
    _WinAPI_SetLayeredWindowAttributes($hBorder, 0xABCDEF, 255)
    ; Desktop und GUI DC holen.
    $hWnd_Desktop = _WinAPI_GetDesktopWindow()
    $hDC_Source = _WinAPI_GetDC($hWnd_Desktop)
    $hDC_Dest = _WinAPI_GetDC($hGUI)
    ;ENDE declare
    ;Schleife
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(75)
    $Pos = MouseGetPos()
    If $Pos[0] <> $PosOld[0] Or $Pos[1] <> $PosOld[1] Then
    WinMove($hBorder, "", $Pos[0] + ($dist / 8), $Pos[1] + ($dist / 8))
    $PosOld = $Pos
    $countLR = 0
    $countHR = 0
    $sl1 = 100
    $sl2 = 100
    GUICtrlSetData($Slider1, $SlScale)
    GUICtrlSetData($Slider2, $SlScale)
    EndIf
    ;Wenn Bewegungstaste gedrückt
    If _IsPressed('25', $dll) And $countLR > $SlScaleMin Then ;links gedrückt
    $countLR = $countLR + (-1)
    $sl1 = $sl1 - 10
    WinMove($hBorder, "", $iX - $Scale, $iY)
    GUICtrlSetData($Slider1, $sl1)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    ElseIf _IsPressed('27', $dll) And $countLR < $SlScaleMax Then ;rechts gedrückt
    $countLR = $countLR + 1
    $sl1 = $sl1 + 10
    WinMove($hBorder, "", $iX + $Scale, $iY)
    GUICtrlSetData($Slider1, $sl1)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    ElseIf _IsPressed('26', $dll) And $countHR > $SlScaleMin Then ;hoch gedrückt
    $countHR = $countHR + (-1)
    $sl2 = $sl2 - 10
    WinMove($hBorder, "", $iX, $iY - $Scale)
    GUICtrlSetData($Slider2, $sl2)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    ElseIf _IsPressed('28', $dll) And $countHR < $SlScaleMax Then ;runter gedrückt
    $countHR = $countHR + 1
    $sl2 = $sl2 + 10
    WinMove($hBorder, "", $iX, $iY + $Scale)
    GUICtrlSetData($Slider2, $sl2)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    EndIf
    ; Winposition abfragen
    $aWinPos = WinGetPos($hBorder)
    $iX = $aWinPos[0] ; x
    $iY = $aWinPos[1] ; y
    $iW = $aWinPos[2] ; width
    $iH = $aWinPos[3] ; height
    ;InfoPost
    ToolTip($countLR & ', ' & $countHR)
    GUICtrlSetData($Input1, 'Maus: x = ' & $Pos[0] & ' , y = ' & $Pos[1])
    GUICtrlSetData($Input2, 'Auswahl: x = ' & $aWinPos[0] & ' , y = ' & $aWinPos[1])
    GUICtrlSetData($Input3, 'Ticks, links: ' & $countLR & ' , Ticks, rechts ' & $countHR)
    ; Bild per StretchBlt übertragen
    _WinAPI_StretchBlt( _
    $hDC_Dest, 0, 0, 200, 200, _
    $hDC_Source, $iX, $iY, $iW, $iH, _
    $SRCCOPY)
    WEnd
    ;Funktionen
    Func _WinAPI_StretchBlt($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRop)
    ; See _WinAPI_BitBlt
    Local $Ret = DllCall('gdi32.dll', 'int', 'StretchBlt', 'hwnd', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidthDest, 'int', $iHeightDest, 'hwnd', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidthSrc, 'int', $iHeightSrc, 'dword', $iRop)
    If (@error) Or (Not IsArray($Ret)) Then
    Return SetError(1, 0, 0)
    EndIf
    Return 1
    EndFunc ;==>_WinAPI_StretchBlt
    Func Beenden()
    Exit
    EndFunc ;==>Beenden

    [/autoit]