PixelGetColor Tool mit Lupe.

  • Hi..

    also, da ja angeblich nur Übung den Meister macht, hab ich mich vorhin hingesetzt und ein kleines Tool angefangen. Ja, es gibt davon schon tausende, aber zum üben ist ja alles geeignet.
    einmal mein Script:

    Spoiler anzeigen
    [autoit]

    #include
    #include
    #include
    HotKeySet ("{F3}", "Pause")
    #Region ### START Koda GUI section ### Form=D:\Dokumente und Einstellungen\^T!Tu$\Eigene Dateien\Form1COLOR.kxf
    $Gui = GUICreate("PixelGetColor", 328, 147, 268, 207)
    $pos = GUICtrlCreateGroup("Position", 0, 0, 137, 57)
    $x = GUICtrlCreateLabel("X : ", 8, 16, 20, 17)
    $Y = GUICtrlCreateLabel("Y : ", 8, 32, 20, 17)
    $xCoord = GUICtrlCreateInput("", 32, 16, 66, 15, $ES_CENTER)
    $yCoord = GUICtrlCreateInput("", 32, 32, 66, 15, $ES_CENTER)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group1 = GUICtrlCreateGroup("Color", 0, 56, 137, 81)
    $decimal = GUICtrlCreateLabel("Decimal :", 8, 72, 48, 17)
    $hex = GUICtrlCreateLabel("Hex : ", 8, 88, 32, 17)
    $decimalColor = GUICtrlCreateInput("", 56, 72, 57, 15)
    $hexColor = GUICtrlCreateInput("", 56, 88, 57, 15)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group2 = GUICtrlCreateGroup("RGB", 144, 0, 97, 73)
    $red = GUICtrlCreateLabel("Red : ", 152, 16, 33, 17)
    $green = GUICtrlCreateLabel("Green : ", 152, 32, 42, 17)
    $blue = GUICtrlCreateLabel("Blue : ", 152, 48, 34, 17)
    $redColor = GUICtrlCreateInput("", 192, 16, 41, 15, $ES_CENTER)
    $greenColor = GUICtrlCreateInput("", 192, 32, 41, 15, $ES_CENTER)
    $blueColor = GUICtrlCreateInput("", 192, 48, 41, 15, $ES_CENTER)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    ;~ 419, 321
    $Label1 = GUICtrlCreateLabel("Press F3 start or Stop the Script!", 270, 80, 50, 57)
    $Start = GUICtrlCreateButton("Start", 264, 8, 57, 25, 0)
    $Exit = GUICtrlCreateButton("Exit", 264, 40, 57, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE, $Exit
    Exit
    Case $Start
    GuiCTRLSetData ($Start, "Stop")
    Do
    $pos = MouseGetPos()
    $color = PixelGetColor ($Pos[0], $pos[1])
    GuiCTRLSetData ($xCoord, $pos[0])
    GuiCTRLSetData ($yCoord, $Pos[1])
    GuiCTRLSetData ($decimalColor, $Color)
    GuiCTRLSetData ($hexColor, Hex($Color))
    GuiCTRLSetData ($RedColor, _ColorGetRed ($color))
    GuiCTRLSetData ($greenColor, _ColorGetGreen ($Color))
    GuiCTRLSetData ($blueColor, _ColorGetBlue ($color))
    Until GUIGetMsg() = $start
    GuiCTRlSetData ($Start, "Start")

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

    EndSwitch
    WEnd

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

    func pause()
    ControlFocus ($Gui, "", 24)
    ControlClick ($Gui, "", 24)
    EndFunc

    [/autoit]


    -> Includes
    GUIConstants.au3
    String.au3
    Color.au3

    und die Bildschirmlupe

    Spoiler anzeigen
    [autoit]

    #include

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

    GUICreate("Lupe",202,202,@DesktopWidth-204,0,$WS_BORDER)
    GUISetState (@SW_SHOW)

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

    $hwnd = DllCall("user32.dll","hwnd","GetDesktopWindow")
    $DC = DllCall("user32.dll","ptr","GetWindowDC","hwnd",$hwnd[0])

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

    $lpRect = DllStructCreate("int;int;int;int")
    DllCall("user32.dll","int","GetWindowRect","hwnd",$hwnd[0],"ptr",DllStructGetPtr($lpRect))

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

    $cDC = DllCall("gdi32.dll","ptr","CreateCompatibleDC","ptr",$DC[0])
    $hbmp = DllCall("gdi32.dll","hwnd","CreateCompatibleBitmap","ptr",$DC[0],"int",DllStructGetData($lpRect,3),"int",DllStructGetData($lpRect,3))
    DllCall("gdi32.dll","hwnd","SelectObject","ptr",$cDC[0],"hwnd",$hbmp[0])

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

    While 1
    $msg = GUIGetMsg()
    Lupe()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend

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

    DllCall("user32.dll","int","ReleaseDC","hwnd",$hwnd[0],"ptr",$cDC[0])
    DllCall("user32.dll","int","ReleaseDC","hwnd",$hwnd[0],"ptr",$DC[0])

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

    Exit

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

    Func Lupe()
    $pos = MouseGetPos()
    If $pos[0] < 50 Then $pos[0] = 50
    If $pos[1] < 50 Then $pos[1] = 50
    If $pos[0] >= (@DesktopWidth - 50) Then $pos[0] = @DesktopWidth - 50
    If $pos[1] >= (@DesktopHeight - 50) Then $pos[1] = @DesktopHeight - 50

    DllCall("gdi32.dll","int","BitBlt","ptr",$cDC[0],"int",0,"int",0,"int",100,"int",100,"ptr",$DC[0],"int",$pos[0]-50,"int",$pos[1]-50,"int",0x00CC0020)

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

    $GUIhwnd = WinGetHandle("Lupe")
    $GUIDC = DllCall("user32.dll","ptr","GetWindowDC","hwnd",$GUIhwnd)
    DllCall("gdi32.dll","int","StretchBlt","ptr",$GUIDC[0],"int",2,"int",2,"int",200,"int",200,"ptr",$cDC[0],"int",0,"int",0,"int",100,"int",100,"int",0x00CC0020)
    EndFunc

    [/autoit]


    -> Includes
    GUIConstants.au3

    meine fragen dazu.. wie krieg ich es hin, dass entweder
    1.) die Bildschirmlupe extern, sprich in einem neuen Gui
    2.) die Lupe in meinem Gui/Script
    ständig aktuallisiert wird?

    Mfg ^T!Tu$

    //Edit:
    ok habs. :P zu mindest 1.) ^^
    noch eine frage die dazu kommt. wie bekomm ich die maus mit in die lupe?

    Einmal editiert, zuletzt von ^T!Tu$ (11. Januar 2008 um 02:48)