Farbe eines Bildfensters ändern

  • Mit welchem Befehl kann ich die Farbe, die ein Bildfeld in der GUI hat, ändern? Mit GUICtrlSetBkColor geht das ja nicht...

    Einmal editiert, zuletzt von NoName (8. Februar 2008 um 23:46)

  • ich glaube gar nicht. aber beschreibe doch mal was du überhaupt damit machen willst, vllt gibt es ja noch einen anderen weg ans ziel zu kommen ;)

  • [autoit]


    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Admin\Desktop\AutoIt\Koda\MouseTool.kxf
    $Form1 = GUICreate("MouseTool", 252, 175, 215, 243)
    $input = GUICtrlCreateInput("", 160, 118, 81, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    $color2=PixelGetColor(MouseGetPos(0),MouseGetPos(1))
    GUICtrlSetBkColor($input,$color2)
    WEnd

    [/autoit]

    Ich gebe die aktuelle Farbe im Moment in einer Inputbox aus... Nur ist das so ziemlich blöd...

  • Du suchst GUISetBkColor :)
    Vorschläge:
    Die Gui noch mit der Maus bewegen
    Im Input den Hex-Wert der Farbe anzeigen
    Input mit $ES_READONLY nur lesbar machen
    Window immer im vordergrund
    Hotkey, um Farbänderung zu pausieren

  • Vorschläge:
    Die Gui noch mit der Maus bewegen
    Im Input den Hex-Wert der Farbe anzeigen
    Input mit $ES_READONLY nur lesbar machen
    Window immer im vordergrund
    Hotkey, um Farbänderung zu pausieren


    Hab nur einen Teil des Programmes angegeben. Was da noch drin ist, ist z.B., dass es immer die aktuelle Mausposition angibt, dass es den Farbcode des aktuellen Pixels in diesem Zahlenwert angibt (Standart), im Hex-Wert und dass man die Maus auf einen bestimten Pixel lenken kann.

    Du suchst GUISetBkColor :)


    Das benutze ich ja schon, und bei Bilder klappt das mit BkColor nicht.

    Mein Problem:
    Wenn ihr das von mir oben ausprobiert, dann werdet ihr feststellen, dass es richtig flimmert. Wie kann ich das vermeiden?

  • Teste mal, ein Label zu nehmen, bei dem du die BKFarbe änderst. Vllt flimmert es dann nicht so :)

  • Teste mal, ein Label zu nehmen, bei dem du die BKFarbe änderst. Vllt flimmert es dann nicht so :)


    Danke. flimmert zwar auch, aber das stört nicht mehr...
    Habe noch ein Problem mit dem Script. Wenn ich es pausiere, muss man nur in das Fenster klicken, und das Prog startet wieder. Das nervt, weil man so nicht die Farben oder was auch immer aus den Inputboxen markieren+kopieren kann... Wie get das weg? Hier der Code:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("MouseTool", 252, 175, 215, 243)
    GUISetBkColor (0x909090)
    $setpos = GUICtrlCreateButton("Set Mouse Position", 24, 124, 107, 17, 0)
    $Label1 = GUICtrlCreateLabel("Mouse Position:", 48, 16, 79, 17)
    $x = GUICtrlCreateInput("", 32, 40, 33, 21,$ES_READONLY)
    $y = GUICtrlCreateInput("", 104, 40, 33, 21,$ES_READONLY)
    $Label2 = GUICtrlCreateLabel("X", 16, 43, 11, 17)
    $Label3 = GUICtrlCreateLabel("Y", 88, 43, 11, 17)
    $Label4 = GUICtrlCreateLabel("Set Mouse Position to:", 24, 72, 110, 17)
    $setx = GUICtrlCreateInput("", 32, 92, 33, 21)
    $sety = GUICtrlCreateInput("", 104, 92, 33, 21)
    $Label5 = GUICtrlCreateLabel("X", 16, 95, 11, 17)
    $Label6 = GUICtrlCreateLabel("Y", 88, 95, 11, 17)
    $Label7 = GUICtrlCreateLabel("Color of current pixel:", 144, 16, 103, 17)
    $Label8 = GUICtrlCreateLabel("As Hex-Value", 162, 70, 68, 17)
    $color = GUICtrlCreateInput("", 160, 40, 81, 21,$ES_READONLY)
    $colorhex = GUICtrlCreateInput("", 160, 88, 81, 21,$ES_READONLY)
    GUICtrlCreateLabel("", 160, 118, 81, 18)
    GUICtrlSetBkColor(-1,0xFFFFFF)
    $outcolor = GUICtrlCreateLabel("", 161, 119, 79, 16)
    $ontop = GUICtrlCreateCheckbox("Set MouseTool always on top", 15, 149, 161, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    GUICtrlSetBkColor($setpos, 0xEEA72C)
    GUICtrlSetBkColor($x, 16777215)
    GUICtrlSetBkColor($y, 16777215)
    GUICtrlSetBkColor($color, 16777215)
    GUICtrlSetBkColor($colorhex, 16777215)
    GUICtrlSetBkColor($x, 16777215)

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

    GUICtrlSetData($setx,"0")
    GUICtrlSetData($sety,"0")

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

    HotKeySet("{F9","start")
    HotKeySet("{F10","pause")

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

    start()

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

    Func start()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $setpos
    MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
    EndSwitch
    start2()
    ontop()
    WEnd
    EndFunc

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

    Func start2()
    GUICtrlSetData($x,MouseGetPos(0))
    GUICtrlSetData($y,MouseGetPos(1))

    GUICtrlSetData($color,PixelGetColor(MouseGetPos(0),MouseGetPos(1)))

    $hex=PixelGetColor(MouseGetPos(0),MouseGetPos(1))
    GUICtrlSetData($colorhex,"0x" & Hex($hex,6))

    $color2=PixelGetColor(MouseGetPos(0),MouseGetPos(1))
    GUICtrlSetBkColor($outcolor,$color2)
    EndFunc

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

    Func ontop()
    If GUICtrlRead($ontop) = $GUI_CHECKED Then
    WinSetOnTop("MouseTool","",1)
    ElseIf GUICtrlRead($ontop) = $GUI_UNCHECKED Then
    WinSetOnTop("MouseTool","",0)
    EndIf
    EndFunc

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

    Func pause()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $setpos
    MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
    EndSwitch
    WEnd
    EndFunc

    [/autoit]


    Habs selber gelöst, bei der pause Funktion hab ich einfach Sleep(10) eingefügt, hier mein fertiges Script:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("MouseTool", 252, 175, 215, 243)
    GUISetBkColor (0x909090)
    $ontop = GUICtrlCreateCheckbox("Set MouseTool always on top", 15, 149, 161, 17)
    $x = GUICtrlCreateInput("", 32, 40, 33, 21,$ES_READONLY)
    $y = GUICtrlCreateInput("", 104, 40, 33, 21,$ES_READONLY)
    $setx = GUICtrlCreateInput("", 32, 92, 33, 21)
    $sety = GUICtrlCreateInput("", 104, 92, 33, 21)
    $setpos = GUICtrlCreateButton("Set Mouse Position", 24, 124, 107, 17, 0)
    $color = GUICtrlCreateInput("", 160, 40, 81, 21,$ES_READONLY)
    $colorhex = GUICtrlCreateInput("", 160, 88, 81, 21,$ES_READONLY)
    $Label1 = GUICtrlCreateLabel("Mouse Position:", 48, 16, 79, 17)
    $Label2 = GUICtrlCreateLabel("X", 16, 43, 11, 17)
    $Label3 = GUICtrlCreateLabel("Y", 88, 43, 11, 17)
    $Label4 = GUICtrlCreateLabel("Set Mouse Position to:", 24, 72, 110, 17)
    $Label5 = GUICtrlCreateLabel("X", 16, 95, 11, 17)
    $Label6 = GUICtrlCreateLabel("Y", 88, 95, 11, 17)
    $Label7 = GUICtrlCreateLabel("Color of current pixel:", 144, 16, 103, 17)
    $Label8 = GUICtrlCreateLabel("As Hex-Value", 162, 70, 68, 17)
    GUICtrlCreateLabel("", 160, 118, 81, 18)
    GUICtrlSetBkColor(-1,0xFFFFFF)
    $Label7 = GUICtrlCreateLabel("F9 = Start F10 = Stop", 0, 0, 130, 17)
    $outcolor = GUICtrlCreateLabel("", 161, 119, 79, 16)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    GUICtrlSetBkColor($setpos, 0xEEA72C)
    GUICtrlSetBkColor($x, 16777215)
    GUICtrlSetBkColor($y, 16777215)
    GUICtrlSetBkColor($color, 16777215)
    GUICtrlSetBkColor($colorhex, 16777215)
    GUICtrlSetBkColor($x, 16777215)

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

    GUICtrlSetData($setx,"0")
    GUICtrlSetData($sety,"0")

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

    HotKeySet("{F9}","start")
    HotKeySet("{F10}","pause")

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

    start()

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

    Func start()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $setpos
    MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
    EndSwitch
    start2()
    ontop()
    WEnd
    EndFunc

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

    Func start2()
    GUICtrlSetData($x,MouseGetPos(0))
    GUICtrlSetData($y,MouseGetPos(1))

    $var = PixelGetColor(MouseGetPos(0), MouseGetPos(1))
    GuiCtrlSetData ($Color,$var)

    $hex=PixelGetColor(MouseGetPos(0),MouseGetPos(1))
    GUICtrlSetData($colorhex,"0x" & Hex($hex,6))

    $color2=PixelGetColor(MouseGetPos(0),MouseGetPos(1))
    GUICtrlSetBkColor($outcolor,$color2)
    EndFunc

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

    Func ontop()
    If GUICtrlRead($ontop) = $GUI_CHECKED Then
    WinSetOnTop("MouseTool","",1)
    ElseIf GUICtrlRead($ontop) = $GUI_UNCHECKED Then
    WinSetOnTop("MouseTool","",0)
    EndIf
    EndFunc

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

    Func pause()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $setpos
    MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
    EndSwitch
    Sleep(10)
    WEnd
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von NoName (8. Februar 2008 um 18:29)

  • Gegen das Flackern: Nur updaten, wenn sich die Farbe ändert.
    D.h.Wenn aktuelle Farbe <> gespeicherte Farbe dann update und aktuelle Farbe speichern :)

  • Du holst ja die Farbe mit PixelGetColor
    Dann machst du einfach Am ScriptAnfang
    $OldColor = -1

    Und bei der Abfrage

    [autoit]

    $mouse = MouseGetPos()
    $color2=PixelGetColor($mouse[0],$mouse[1])
    If $color2 <> $OLDcolor Then
    ; Hier das, was du machen willst
    $OLDcolor = $color2
    EndIf

    [/autoit]
  • Ok, vielen Dank, wieder was dazugelernt :)
    Code:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Admin\Desktop\AutoIt\Koda\MouseTool.kxf
    $Form1 = GUICreate("MouseTool", 252, 175, 215, 243)
    GUISetBkColor (0x909090)
    $ontop = GUICtrlCreateCheckbox("MouseTool always on top", 12, 149, 145, 17)
    $x = GUICtrlCreateInput("", 32, 40, 33, 21,$ES_READONLY)
    $y = GUICtrlCreateInput("", 104, 40, 33, 21,$ES_READONLY)
    $setx = GUICtrlCreateInput("", 32, 92, 33, 21)
    $sety = GUICtrlCreateInput("", 104, 92, 33, 21)
    $setpos = GUICtrlCreateButton("Set Mouse Position", 24, 124, 107, 17, 0)
    $color = GUICtrlCreateInput("", 160, 40, 81, 21,$ES_READONLY)
    $colorhex = GUICtrlCreateInput("", 160, 88, 81, 21,$ES_READONLY)
    $Label1 = GUICtrlCreateLabel("Mouse Position:", 48, 16, 79, 17)
    $Label2 = GUICtrlCreateLabel("X", 16, 43, 11, 17)
    $Label3 = GUICtrlCreateLabel("Y", 88, 43, 11, 17)
    $Label4 = GUICtrlCreateLabel("Set Mouse Position to:", 24, 72, 110, 17)
    $Label5 = GUICtrlCreateLabel("X", 16, 95, 11, 17)
    $Label6 = GUICtrlCreateLabel("Y", 88, 95, 11, 17)
    $Label7 = GUICtrlCreateLabel("Color of current pixel:", 144, 16, 103, 17)
    $Label8 = GUICtrlCreateLabel("As Hex-Value", 162, 70, 68, 17)
    GUICtrlCreateLabel("", 160, 118, 81, 42)
    GUICtrlSetBkColor(-1,0xFFFFFF)
    $Label7 = GUICtrlCreateLabel("F9 = Start F10 = Stop", 0, 0, 130, 17)
    $outcolor = GUICtrlCreateLabel("", 161, 119, 79, 40)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    GUICtrlSetBkColor($setpos, 0xEEA72C)
    GUICtrlSetBkColor($x, 16777215)
    GUICtrlSetBkColor($y, 16777215)
    GUICtrlSetBkColor($color, 16777215)
    GUICtrlSetBkColor($colorhex, 16777215)
    GUICtrlSetBkColor($x, 16777215)

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

    GUICtrlSetData($setx,"0")
    GUICtrlSetData($sety,"0")

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

    HotKeySet("{F9}","start")
    HotKeySet("{F10}","pause")

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

    $OLDColor = -1
    start()

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

    Func start()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $setpos
    MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
    EndSwitch
    start2()
    ontop()
    WEnd
    EndFunc

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

    Func start2()
    GUICtrlSetData($x,MouseGetPos(0))
    GUICtrlSetData($y,MouseGetPos(1))

    $var = PixelGetColor(MouseGetPos(0), MouseGetPos(1))
    GuiCtrlSetData ($Color,$var)

    $hex=PixelGetColor(MouseGetPos(0),MouseGetPos(1))
    GUICtrlSetData($colorhex,"0x" & Hex($hex,6))


    $mouse = MouseGetPos()
    $color2=PixelGetColor($mouse[0],$mouse[1])
    If $color2 <> $OLDcolor Then
    GUICtrlSetBkColor($outcolor,GUICtrlRead($color))
    $OLDcolor = $color2
    EndIf
    EndFunc

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

    Func ontop()
    If GUICtrlRead($ontop) = $GUI_CHECKED Then
    WinSetOnTop("MouseTool","",1)
    ElseIf GUICtrlRead($ontop) = $GUI_UNCHECKED Then
    WinSetOnTop("MouseTool","",0)
    EndIf
    EndFunc

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

    Func pause()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $setpos
    MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
    EndSwitch
    Sleep(10)
    WEnd
    EndFunc

    [/autoit]

    Hab noch ml eine Frage: Kann ich ein Fenster per AutoIt machen, welches nicht den Balken oben mit Minimieren, Vergrößern und scließen hat? Sodass gleich das programm selbst kommt...

    Einmal editiert, zuletzt von NoName (8. Februar 2008 um 21:43)