Pixelfabre bestimmen?

  • Hallo,
    kann man irgendwie die Farbe eines Pixels ändern, bzw. bestimmen? Z. B. Solange das Skript läuft soll der Pixel was-weiß-ich immer die Farbe rot haben.
    Ich habe nur gefunden in der Hilfe das man die farbe auslesen kann etc.
    danke und Gruß

    Einmal editiert, zuletzt von Vaerldskrig (9. Januar 2010 um 17:13)

  • Du kannst eine GUI mit entsprechender Größe erstellen und ihr dann eine Hintergrundfarbe zuweisen:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    GUICreate("Test", 1, 1, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
    $deinefarbe = 0xFF0000
    GUISetBkColor($deinefarbe)
    GUISetState()
    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
    Exit

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • den gedanken mit der GUI hatte ich auch scohn, aber weiß nicht. Auf jeden fall siehts nicht mal so dumm aus. danke erstmal.
    aber das blöde ist eben das es eben in hintergrund gerät wenn man ein anderes fenster aktiv hat etc...

  • um Pixel an einer bestimmten Position zu setzen verwende ich gerne

    [autoit]

    #include <WindowsConstants.au3>
    #include <WinAPI.au3>
    HotKeySet("{ESC}","_exit")

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

    Local $hDC, $hPen, $obj_orig
    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, 1, 0x0000FF)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)

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

    while 1
    $x1=random(1,@DesktopWidth,1)
    $y1=random(1,@Desktopheight,1)
    _WinAPI_DrawLine($hDC, $X1, $Y1, $X1+1, $Y1+1)
    wend

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

    func _exit()
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    ; clear resources
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
    exit
    endfunc

    [/autoit]
  • Ich hab mal sowas hier gemacht... UNd funzt auch eig ganz gut :)

    [autoit]

    $Color = 0x0000FF
    $Handle = "$WS_EX_TOPMOST"

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

    $x1 = 639
    $y1 = 399
    $x2 = 640
    $y2 = 399
    $x3 = 641
    $y3 = 399
    $x4 = 639
    $y4 = 400
    $x5 = 640
    $y5 = 400
    $x6 = 641
    $y6 = 400
    $x7 = 639
    $y7 = 401
    $x8 = 640
    $y8 = 401
    $x9 = 641
    $y9 = 401

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

    While 1
    $GetDC = DllCall ("user32.dll", "int", "GetDC", "hwnd", $Handle)

    $SetPixel1 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x1, "long", $y1, "long", $Color)
    $SetPixel2 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x2, "long", $y2, "long", $Color)
    $SetPixel3 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x3, "long", $y3, "long", $Color)
    $SetPixel4 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x4, "long", $y4, "long", $Color)
    $SetPixel5 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x5, "long", $y5, "long", $Color)
    $SetPixel6 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x6, "long", $y6, "long", $Color)
    $SetPixel7 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x7, "long", $y7, "long", $Color)
    $SetPixel8 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x8, "long", $y8, "long", $Color)
    $SetPixel9 = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $x9, "long", $y9, "long", $Color)

    $ReleaseDC = DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $GetDC[0])
    WEnd

    [/autoit]


    Gruß AndyTR :)

  • Ich hab mal sowas hier gemacht... UNd funzt auch eig ganz gut

    Kanns leider nicht testen - bin grad am Netbook ohne AutoIt.
    Aber so ist dein script um einiges kürzer:

    Spoiler anzeigen
    [autoit]

    $Color = 0x0000FF
    $Handle = "$WS_EX_TOPMOST"
    Dim $Coord[8][2] = [[639,399],[640,399],[641,399],[639,400],[640,400],[641,400],[639,401],[640,401],[641,401]]
    Dim $SetPixel[8]
    While 1 * sleep(20)
    $GetDC = DllCall ("user32.dll", "int", "GetDC", "hwnd", $Handle)
    For $i = 0 to 8
    $SetPixel[$i] = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $Coord[$i][0], "long", $Coord[$i][1], "long", $Color)
    Next
    $ReleaseDC = DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $GetDC[0])
    WEnd

    [/autoit]
  • AndyTR Ja, ddeins funktioniert auch sehr gut, danke.
    @ Seubo deins bringt bei mir einen fehler:
    C:\Dokumente und Einstellungen\...\...\***.au3 (3) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
    Dim $Coord[8][2] = [[639,399],[640,399],[641,399],[639,400],[640,400],[641,400],[639,401],[640,401],[641,401]]
    Dim $Coord[8][2] = [[639,399],[640,399],[641,399],[639,400],[640,400],[641,400],[639,401],[640,401],[^ ERROR
    >Exit code: 1 Time: 0.336

  • Dann versuch mal:

    Spoiler anzeigen
    [autoit]

    $Color = 0x0000FF
    $Handle = "$WS_EX_TOPMOST"
    Dim $Coord[9][2] = [[639,399],[640,399],[641,399],[639,400],[640,400],[641,400],[639,401],[640,401],[641,401]]
    Dim $SetPixel[9]
    While 1 * sleep(20)
    $GetDC = DllCall ("user32.dll", "int", "GetDC", "hwnd", $Handle)
    For $i = 0 to 9
    $SetPixel[$i] = DllCall ("gdi32.dll", "long", "SetPixel", "long", $GetDC[0], "long", $Coord[$i][0], "long", $Coord[$i][1], "long", $Color)
    Next
    $ReleaseDC = DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $GetDC[0])
    WEnd

    [/autoit]