PixelGetColor Frage! - Keine NoobFrage

  • Hey
    Also ich habe folgendes versucht:
    Ich möchte nach einem Feld suche, die eine bestimmte Farbe hat. In dem Feld ist ein Feld das aber nicht diese Farbe hat. Die Koordinaten (also die ganzen Coords. x und y von allen Punkten) will ich wissen.
    Mein Skript:

    [autoit]


    $color=13884907
    For $i=0 To @DesktopWidth
    For $e=0 To @DesktopHeight
    If PixelGetColor($i,$e)=$color Then
    ;Hier Kommt Das Hin Wo Ran Ich Gescheitert bin
    ;So Was Wie Wenn Die Letzte Position nicht um eins höher ist dann merke dir Zahl
    EndIf
    Next
    Next

    [/autoit]


    hope4me ihr versteht
    thx4help :thumbup:

    Nur keine Hektik - das Leben ist stressig genug

  • Ich will einen "guten" Draw-Bot erstellen.
    Also kein Bot im schlechtem sinne. (Die anderen sind so was von schwarz-weiß :D )

    Nur keine Hektik - das Leben ist stressig genug

  • HallloooO? 8|
    Ich hätte bestimmt nicht gefragt, wenn ich die Lösung in 5min hätte!
    Also: Ich habe über 2std daran gesessen und immer! immer! hatte ich falsche korrd. heraus.
    Pls schreibt doch mal einen Skript. Währe sehr nett.

    Nur keine Hektik - das Leben ist stressig genug

  • Habe dafür letztens was erstellt. musst nur noch die für dich wichtigen Teile raussuchen.

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GDIPlusConstants.au3>
    #include <WinAPI.au3>
    #include <Array.au3>
    #include <ScreenCapture.au3>
    _GDIPlus_Startup()

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

    $hCapture1 = _Capture(1, 1, 77, 55) ; Screencapture machen (Bereich 1,1 -> 77,55)
    $aTest = _GDIPlus_ImageGetColorArray($hCapture1) ; Farbinformationen in Array einlesen

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

    MouseMove(10, 10, 0)

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

    $hCapture2 = _Capture(1, 1, 77, 55) ; Neues Bild
    $aTest2 = _GDIPlus_ImageGetColorArray($hCapture2) ; Neues Bild einlesen

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

    $aUnterschiede = _GetColorDifferences($aTest, $aTest2) ; Unterschiede finden (Koordinaten)

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

    ;Ab hier dient es nur noch der Darstellugn.

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

    _Display($aTest, "Vorher") ; Vorher Bild anzeigen
    _Display($aTest2, "Nachher") ; Nachher Bild anzeigen
    _Display($aTest2, "Unterschiede", $aUnterschiede) ; Unterschiede anhand der Koordinaten markieren

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

    _ArrayDisplay($aUnterschiede, "Alle unterschiede:")

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

    _GDIPlus_Shutdown()

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

    Func _GetColorDifferences($aBefore, $aAfter)
    Local $iUB1[2] = [UBound($aBefore), UBound($aBefore, 2)], $iUB2[2] = [UBound($aAfter), UBound($aAfter, 2)]
    Local $iDim = $iUB1, $aRet[1][2] = [[0]], $iUB = 0
    If $iDim[0] > $iUB2[0] Then $iDim[0] = $iUB2[0]
    If $iDim[1] > $iUB2[1] Then $iDim[1] = $iUB2[1]

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

    For $i = 0 To $iDim[0] - 1
    For $j = 0 To $iDim[1] - 1
    If $aBefore[$i][$j] <> $aAfter[$i][$j] Then
    Local $iUB = UBound($aRet)
    ReDim $aRet[$iUB + 1][2]
    $aRet[$iUB][0] = $i
    $aRet[$iUB][1] = $j
    EndIf
    Next
    Next
    $aRet[0][0] = $iUB
    Return $aRet
    EndFunc ;==>_GetColorDifferences

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

    Func _GDIPlus_ImageGetColorArray($sFile)
    ; SEuBo - Thx to Andy for
    ; https://autoit.de/index.php?page…6673#post126673
    Local $iWidth, $iHeight, $iStride
    Local $hBitMap, $hBitMapData, $hPixelData
    If FileExists($sFile) Then $hBitMap = _GDIPlus_BitmapCreateFromFile($sFile)
    If Not FileExists($sFile) Then $hBitMap = _GDIPlus_BitmapCreateFromHBITMAP($sFile)
    $hBitMapData = _GDIPlus_BitmapLockBits($hBitMap, 0, 0, _GDIPlus_ImageGetWidth($hBitMap), _GDIPlus_ImageGetHeight($hBitMap), $GDIP_ILMREAD, $GDIP_PXF24RGB)
    If @error Then Return SetError(1, 0, 0)
    $iWidth = DllStructGetData($hBitMapData, "Width");Image width - Number of pixels in one scan line of the bitmap.
    $iHeight = DllStructGetData($hBitMapData, "Height");Image height - Number of scan lines in the bitmap.
    $hPixelData = DllStructCreate("ubyte[" & (Abs(DllStructGetData($hBitMapData, "Stride")) * ($iHeight)) & "]", DllStructGetData($hBitMapData, "Scan0"))
    _WinAPI_DeleteObject($hBitMap)
    _GDIPlus_BitmapUnlockBits($hBitMap, DllStructGetData($hPixelData, 1))

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

    Local $aReturn[$iWidth][$iHeight], $i = 1
    For $y = 0 To $iHeight - 1
    For $x = 0 To $iWidth - 1
    $aReturn[$x][$y] = "0x" & Hex(DllStructGetData($hPixelData, 1, $i + 2), 2) & Hex(DllStructGetData($hPixelData, 1, $i + 1), 2) & Hex(DllStructGetData($hPixelData, 1, $i), 2)
    $i += 3
    Next
    Next
    _GDIPlus_ImageDispose($hPixelData) ;destroys the pixeldatastruct, have to be done at end of the script!
    Return $aReturn
    EndFunc ;==>_GDIPlus_ImageGetColorArray

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

    Func _Display($aTest, $sTitle = "", $aDiff = 0)
    $hGUI = GUICreate($sTitle, UBound($aTest, 1) * 10, UBound($aTest, 2) * 10)
    If IsArray($aDiff) Then
    For $i = 1 To UBound($aDiff) - 1
    $aTest[$aDiff[$i][0]][$aDiff[$i][1]] = 0xFF0000
    Next
    EndIf

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

    For $1 = 0 To UBound($aTest) - 1
    For $2 = 0 To UBound($aTest, 2) - 1
    GUICtrlCreateGraphic($1 * 10, $2 * 10, 10, 10)
    GUICtrlSetBkColor(-1, $aTest[$1][$2])
    Next
    Next

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

    GUISetState()

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    ExitLoop
    EndSwitch
    WEnd
    GUIDelete($hGUI)
    EndFunc ;==>_Display

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

    Func _Capture($iLeft, $iTop, $iRight, $iBottom, $sFile = "")
    Local $iWidth = $iRight - $iLeft + 1, $iHeight = $iBottom - $iTop + 1
    If Mod($iWidth, 4) Then $iWidth += (4 - Mod($iWidth, 4))
    If Mod($iHeight, 4) Then $iHeight += (4 - Mod($iHeight, 4))
    $iRight = $iWidth + $iLeft -1
    $iBottom = $iHeight + $iTop -1
    ConsoleWrite("_ScreenCapture_Capture(" & $sFile & ", " & $iLeft & ", " & $iTop & ", " & $iRight & ", " & $iBottom & ")" & @CRLF)
    Return _ScreenCapture_Capture($sFile, $iLeft, $iTop, $iRight, $iBottom)
    EndFunc ;==>_Capture

    [/autoit]

    //EDIT: Merk grad, dass ich ein bisschen am Thema vorbei geschossen bin. Naja vllt hilft das ja trotzdem nochmal.

  • Hmm. Ich glaube du verstehst mich nicht oder ich versteh deinen Skript nicht ^^ .
    Also nochmal: :rolleyes:
    Ich habe ein, sagen wir haben ein blaues Feld. Darin ist ein graues Feld. In dem grauem Feld ist ein weißes.
    Jetzt suche ich einfach das graue ab nach seinen Koords. Jetzt erhalte ich aber nicht alles wegen dem weißem.
    Und die Koords. die ich nicht erhalten habe DIE will ich haben.

    Nur keine Hektik - das Leben ist stressig genug

  • Hallo AntiSpeed,

    nach 64 Minuten schon pushen, wird in diesem Forum gar nicht gerne gesehen und du solltest deinem Namen zu Ehre dich etwas mehr in Geduld üben.
    Deine speziellen Frage sieht verdächtig nach etwas aus, was unseren Forenregeln widerspricht. Falls du denkst, dass der Verdacht unbegründet ist, erkläre bitte genau, wozu das Skript dienen soll.

    mfg (Auto)Bert

  • *hust*
    Also ich bin der Letzte der ein Bot (also so was wie du meins erstellt).

    Zitat

    Ich will einen "guten" Draw-Bot erstellen.
    Also kein Bot im schlechtem sinne. (Die anderen sind so was von schwarz-weiß :D )

    Also ok ich mach ein ScreenShot sons wird das hier garnix mehr... :wacko:
    Im Anhang ist der ScreenShot. Ich möchte die Koord. aus dem weißem Feld (MalFeld) auslesen [Das wäre ja einfach ABER das Feld ist ja nicht immer weiß.. (bild geladen)].
    Es gibt keine Class oder Sonstiges womit man das Control auslesen könnte.
    Das Fenster ist immer im VollBild.
    Thx4Help