Mit welchem Befehl kann ich die Farbe, die ein Bildfeld in der GUI hat, ändern? Mit GUICtrlSetBkColor geht das ja nicht...
Farbe eines Bildfensters ändern
-
- [ gelöst ]
-
NoName -
7. Februar 2008 um 20:53 -
Geschlossen -
Erledigt
-
-
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]
[/autoit][autoit][/autoit][autoit]
#include <GUIConstants.au3>#Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Admin\Desktop\AutoIt\Koda\MouseTool.kxf
[/autoit][autoit][/autoit][autoit]
$Form1 = GUICreate("MouseTool", 252, 175, 215, 243)
$input = GUICtrlCreateInput("", 160, 118, 81, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###While 1
[/autoit]
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
$color2=PixelGetColor(MouseGetPos(0),MouseGetPos(1))
GUICtrlSetBkColor($input,$color2)
WEndIch gebe die aktuelle Farbe im Moment in einer Inputbox aus... Nur ist das so ziemlich blöd...
-
- Offizieller Beitrag
Verstehe nicht was dir fehlt?
-
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]
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstants.au3>#Region ### START Koda GUI section ### Form=
[/autoit] [autoit][/autoit] [autoit]
$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 ###GUICtrlSetBkColor($setpos, 0xEEA72C)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetBkColor($x, 16777215)
GUICtrlSetBkColor($y, 16777215)
GUICtrlSetBkColor($color, 16777215)
GUICtrlSetBkColor($colorhex, 16777215)
GUICtrlSetBkColor($x, 16777215)GUICtrlSetData($setx,"0")
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetData($sety,"0")HotKeySet("{F9","start")
[/autoit] [autoit][/autoit] [autoit]
HotKeySet("{F10","pause")start()
[/autoit] [autoit][/autoit] [autoit]Func start()
[/autoit] [autoit][/autoit] [autoit]
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $setpos
MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
EndSwitch
start2()
ontop()
WEnd
EndFuncFunc start2()
[/autoit] [autoit][/autoit] [autoit]
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)
EndFuncFunc ontop()
[/autoit] [autoit][/autoit] [autoit]
If GUICtrlRead($ontop) = $GUI_CHECKED Then
WinSetOnTop("MouseTool","",1)
ElseIf GUICtrlRead($ontop) = $GUI_UNCHECKED Then
WinSetOnTop("MouseTool","",0)
EndIf
EndFuncFunc pause()
[/autoit]
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $setpos
MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
EndSwitch
WEnd
EndFuncHabs selber gelöst, bei der pause Funktion hab ich einfach Sleep(10) eingefügt, hier mein fertiges Script:
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstants.au3>#Region ### START Koda GUI section ### Form=
[/autoit] [autoit][/autoit] [autoit]
$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 ###GUICtrlSetBkColor($setpos, 0xEEA72C)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetBkColor($x, 16777215)
GUICtrlSetBkColor($y, 16777215)
GUICtrlSetBkColor($color, 16777215)
GUICtrlSetBkColor($colorhex, 16777215)
GUICtrlSetBkColor($x, 16777215)GUICtrlSetData($setx,"0")
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetData($sety,"0")HotKeySet("{F9}","start")
[/autoit] [autoit][/autoit] [autoit]
HotKeySet("{F10}","pause")start()
[/autoit] [autoit][/autoit] [autoit]Func start()
[/autoit] [autoit][/autoit] [autoit]
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $setpos
MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
EndSwitch
start2()
ontop()
WEnd
EndFuncFunc start2()
[/autoit] [autoit][/autoit] [autoit]
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)
EndFuncFunc ontop()
[/autoit] [autoit][/autoit] [autoit]
If GUICtrlRead($ontop) = $GUI_CHECKED Then
WinSetOnTop("MouseTool","",1)
ElseIf GUICtrlRead($ontop) = $GUI_UNCHECKED Then
WinSetOnTop("MouseTool","",0)
EndIf
EndFuncFunc pause()
[/autoit]
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $setpos
MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
EndSwitch
Sleep(10)
WEnd
EndFunc -
Gegen das Flackern: Nur updaten, wenn sich die Farbe ändert.
D.h.Wenn aktuelle Farbe <> gespeicherte Farbe dann update und aktuelle Farbe speichern -
Doofe Frage... aber wie soll ich die aktuelle Farbe des Labels abspeichern?
-
Du holst ja die Farbe mit PixelGetColor
Dann machst du einfach Am ScriptAnfang
$OldColor = -1Und bei der Abfrage
[autoit]$mouse = MouseGetPos()
[/autoit]
$color2=PixelGetColor($mouse[0],$mouse[1])
If $color2 <> $OLDcolor Then
; Hier das, was du machen willst
$OLDcolor = $color2
EndIf -
Ok, vielen Dank, wieder was dazugelernt
Code:Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstants.au3>#Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Admin\Desktop\AutoIt\Koda\MouseTool.kxf
[/autoit] [autoit][/autoit] [autoit]
$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 ###GUICtrlSetBkColor($setpos, 0xEEA72C)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetBkColor($x, 16777215)
GUICtrlSetBkColor($y, 16777215)
GUICtrlSetBkColor($color, 16777215)
GUICtrlSetBkColor($colorhex, 16777215)
GUICtrlSetBkColor($x, 16777215)GUICtrlSetData($setx,"0")
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetData($sety,"0")HotKeySet("{F9}","start")
[/autoit] [autoit][/autoit] [autoit]
HotKeySet("{F10}","pause")$OLDColor = -1
[/autoit] [autoit][/autoit] [autoit]
start()Func start()
[/autoit] [autoit][/autoit] [autoit]
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $setpos
MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
EndSwitch
start2()
ontop()
WEnd
EndFuncFunc start2()
[/autoit] [autoit][/autoit] [autoit]
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
EndFuncFunc ontop()
[/autoit] [autoit][/autoit] [autoit]
If GUICtrlRead($ontop) = $GUI_CHECKED Then
WinSetOnTop("MouseTool","",1)
ElseIf GUICtrlRead($ontop) = $GUI_UNCHECKED Then
WinSetOnTop("MouseTool","",0)
EndIf
EndFuncFunc pause()
[/autoit]
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $setpos
MouseMove(GUICtrlRead($setx),GUICtrlRead($sety),0)
EndSwitch
Sleep(10)
WEnd
EndFuncHab 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...
-
- Offizieller Beitrag
Schau dir mal GUI-Style $WS_POPUP an.
-
Danke, genau das habe ich gesucht...