Placing pixels in a different window in win32gui

Viewed 151

What I want to do is simply add pixels to the top of any window I choose with setpixel. But the problem is that I couldn't find any resources on this subject. The pixels I add in win32gui.setpixel appear either in the python terminal or on the desktop but they are not visible above chrome, for example.

How can I add pixels above everything or certain tabs?

import win32gui, time
import os

cls = lambda: os.system('cls')
cls()

print("Hazır.")

while True:
    x=int(960)    # 1920 / 2 = 960 for X position on screen.
    y=int(600)    # 1200 / 2 = 600 for Y position on screen.
    color=int(255)   # Pixel color, 255 = Red
    hwnd=win32gui.WindowFromPoint((x,y))
    hdc=win32gui.GetDC(hwnd)
    x1,y1=win32gui.ScreenToClient(hwnd,(x,y))
    win32gui.SetPixel(hdc,x1,y1,color)
    win32gui.SetPixel(hdc,x1-1,y1,color)
    win32gui.SetPixel(hdc,x1+1,y1,color)
    win32gui.SetPixel(hdc,x1,y1-1,color)
    win32gui.SetPixel(hdc,x1,y1+1,color)
    win32gui.SetPixel(hdc,x1-1,y1-1,color)
    win32gui.SetPixel(hdc,x1+1,y1+1,color)
    win32gui.SetPixel(hdc,x1-1,y1+1,color)
    win32gui.SetPixel(hdc,x1+1,y1-1,color)
 
    win32gui.SetPixel(hdc,x1-2,y1,color)
    win32gui.SetPixel(hdc,x1+2,y1,color)
    win32gui.SetPixel(hdc,x1,y1-2,color)
    win32gui.SetPixel(hdc,x1,y1+2,color)
    win32gui.SetPixel(hdc,x1-2,y1-2,color)
    win32gui.SetPixel(hdc,x1+2,y1+2,color)
    win32gui.SetPixel(hdc,x1-2,y1+2,color)
    win32gui.SetPixel(hdc,x1+2,y1-2,color)
 
    win32gui.ReleaseDC(hwnd,hdc)
 
    time.sleep(0.1)
0 Answers
Related