示例#1
0
def draw(pixels, *args):

    if not type(pixels) == list:
        raise TypeError(
            "Invalid pixels. Use the list returned from the 'load' function")

    try:
        duration = args[0]
    except:
        duration = None

    if duration != None:
        start = time.time()

        while True:
            try:
                elapsed = int((time.time() - start) * 1000)

                if not elapsed > duration:
                    for pixel in pixels:
                        win32gui.SetPixel(dc, pixel[0], pixel[1], pixel[2])
                else:
                    break
            except:
                raise TypeError(
                    "Invalid pixels. Use the list returned from the 'load' function"
                )
    else:
        for pixel in pixels:
            win32gui.SetPixel(dc, pixel[0], pixel[1], pixel[2])
示例#2
0
    def climb_to_zero(self, gui):
        v_cursor = (int(self.gui.window.width / 2) - 150,
                    int(self.gui.window.height / 2))
        start_point = v_cursor

        (r, g, b) = cg.get_pixel_color(v_cursor[0], v_cursor[1])

        while ((r, g, b) == tp.OFFMAPCOLOR or (r, g, b) in tp.TREECOLORS):
            if (r, g, b) in tp.TREECOLORS:
                #if we hit a tree, move to the left a bit to make sure we get away
                v_cursor = (v_cursor[0] - 10, v_cursor[1])
                (r, g, b) = cg.get_pixel_color(v_cursor[0], v_cursor[1])
                continue
            win32gui.SetPixel(self.i_desktop_window_dc, v_cursor[0],
                              v_cursor[1], win32api.RGB(0, 255, 0))
            v_cursor = (v_cursor[0], v_cursor[1] + 1)
            (r, g, b) = cg.get_pixel_color(v_cursor[0], v_cursor[1])

        (rr, gr, br) = cg.get_pixel_color(v_cursor[0] + 1, v_cursor[1])
        (rd, gd, bd) = cg.get_pixel_color(v_cursor[0] + 1, v_cursor[1] - 1)
        while ((rr, gr, br) != tp.OFFMAPCOLOR
               or (rd, gd, bd) != tp.OFFMAPCOLOR):
            (rr, gr, br) = cg.get_pixel_color(v_cursor[0] + 1, v_cursor[1])
            (rd, gd, bd) = cg.get_pixel_color(v_cursor[0] + 1, v_cursor[1] - 1)
            win32gui.SetPixel(self.i_desktop_window_dc, v_cursor[0],
                              v_cursor[1], win32api.RGB(0, 255, 0))
            v_cursor = (v_cursor[0] + 2, v_cursor[1] - 1)

        v_cursor = (v_cursor[0] - 3, v_cursor[1] + 1)
        tile_center = (v_cursor[0], v_cursor[1] + round(tp.TILE_HEIGHT / 2))
        return tile_center
示例#3
0
 def drawCross(self, x, y):
     dc = win32gui.GetDC(0)
     red = win32api.RGB(255, 0, 0)
     cont = x - 5
     while cont < x + 5:
         win32gui.SetPixel(dc, cont, y, red)
         cont = cont + 1
     cont2 = y - 5
     while cont2 < y + 5:
         win32gui.SetPixel(dc, x, cont2, red)
         cont2 = cont2 + 1
def drawRect(x1, y1, x2, y2, xDiff, yDiff):
    dc = win32gui.GetDC(0)
    color = win32api.RGB(255, 0, 0)

    while (True):
        global stopDrawing
        for i in range(xDiff):
            win32gui.SetPixel(dc, x1 + i, y1, color)
            win32gui.SetPixel(dc, x2 - i, y2, color)
        for i in range(yDiff):
            win32gui.SetPixel(dc, x1, y1 + i, color)
            win32gui.SetPixel(dc, x2, y2 - i, color)
        if (stopDrawing): break
示例#5
0
    def set_pixel(self, x: int, y: int, color: QColor) -> None:
        """
        Sets the pixel at x,y to color

        Example
        --------
        >>> color = QColor(255, 0, 0)                # Color red
        >>> screen = Screen(create_wxapp=False)     # Does not create wx.App(...)
        >>> screen.set_pixel(24, 24, color)         # Sets the pixel at 24, 24 to variable 'color' (red)
        >>> screen.set_pixel((24, 24), color)       # Sets the pixel at 24, 24 to variable 'color' (red)
        >>> screen.set_pixel(Point(24, 24), color)  # Sets the pixel at 24, 24 to variable 'color' (red)

        >>> color = QColor(255, 0, 0)             # Color red
        >>> pixel = QPixel(24, 24, color)         # Create a pixel instance with red color for position 24, 24
        >>> screen = Screen(create_wxapp=False)  # Does not create wx.App(...)
        >>> screen.set_pixel(pixel)              # Sets the pixel to variable 'pixel'


        :param x: The X coordinate of the pixel to set, must be an integer
        :param y: The Y coordinate of the pixel to set, must be an integer
        :param color: The pixel color to set, must be a Color instance
        :return: Nothing
        """

        if not self._use_pywin32:
            raise ValueError("Can't set pixel without having PyWin32 installed")

        # noinspection PyPackageRequirements
        import win32gui
        import win32api
        red = win32api.RGB(color.r, color.g, color.b)
        win32gui.SetPixel(self.dc, x, y, red)  # draw red at 0,0
示例#6
0
def makeVortex2(xInput, yInput, radius, usedSeed, layers):
    seed(usedSeed)
    lengthOfLayer = radius / layers
    colorListR = []
    colorListG = []
    colorListB = []
    for color in range(0, layers):
        colorListR.append(randint(0, 255))
        colorListG.append(randint(0, 255))
        colorListB.append(randint(0, 255))
    for x in range(round(xInput - radius), round(xInput + radius)):
        for y in range(round(yInput - radius), round(yInput + radius)):
            for layerCount in range(0, layers):
                if (math.sqrt(
                        math.pow(abs(abs(x) - abs(xInput)), 2) +
                        math.pow(abs(abs(y) - abs(yInput)), 2)) <
                        lengthOfLayer * layerCount):
                    color = win32api.RGB(colorListR[layerCount],
                                         colorListG[layerCount],
                                         colorListB[layerCount])
                    try:
                        win32gui.SetPixel(dc, x, y, color)
                    except:
                        pass
                    #workWithImage[x,y] = (colorListR[layerCount], colorListG[layerCount], colorListB[layerCount])
                    break
示例#7
0
def draw_pixel():
    hwin = win32gui.GetDesktopWindow()
    hdc = win32gui.GetDC(hwin)

    # 점찍기
    red = win32api.RGB(255, 0, 0)
    win32gui.SetPixel(hdc, 0, 0, red)
    win32gui.SetPixel(hdc, 0, 1, red)
    win32gui.SetPixel(hdc, 0, 2, red)
    win32gui.SetPixel(hdc, 0, 3, red)

    # 사각형그리기
    pen = win32gui.CreatePen(win32con.PS_SOLID, 5, win32api.RGB(0, 0, 255))
    oldPen = win32gui.SelectObject(hdc, pen)

    win32gui.Rectangle(hdc, 50, 50, 100, 100)
    win32gui.SelectObject(hdc, oldPen)
    win32gui.DeleteObject(pen)
def drawScreenDiagonal(maxWidth, maxHeight):
    ratio = maxHeight / maxWidth
    y = -1
    for x in range(0, maxWidth):
        y += ratio
        if y > maxHeight:
            y = maxHeight
        print("drawing: x=" + str(ceil(x)) + " y=" + str(ceil(y)))
        win32gui.SetPixel(dc, ceil(x), ceil(y), red)
示例#9
0
 def screenglitch(pixelsChanged=5000, delay=10):
     start = identifier
     pixelsChanged = int(pixelsChanged)
     delay = float(delay)
     dc = win32gui.GetDC(0)
     for i in range(pixelsChanged):
         if(start!=identifier):
             return
         x=random.randint(0,win32api.GetSystemMetrics(0)-1)
         y=random.randint(0,win32api.GetSystemMetrics(1)-1)
         r,g,b = random.randint(1,255),random.randint(1,255),random.randint(1,255)
         color = win32api.RGB(r,g,b)
         win32gui.SetPixel(dc, int(x), int(y), color)
         time.sleep(delay/1000)
    def draw_crosshair_pixels(self):
        coords = []
        sleep_time = t = 1 / self.fps
        w = GetSystemMetrics(0) / 2 - self.width / 2 #+ 1
        h = GetSystemMetrics(1) / 2 - self.width / 2 #+ 1
        dc = win32gui.GetDC(0)

        for y in range(self.width):
            for x in range(self.width):
                if self.crosshair_matrix[y][x] != self.transparent_color:
                    coords.append((int(x + w), int(y + h), self.crosshair_matrix[y][x]))

        while self.allow_draw:
            list(map(lambda x: win32gui.SetPixel(dc, x[0], x[1], x[2]), coords))
            time.sleep(sleep_time)
示例#11
0
 def _draw_image(self, handle: int, paint, box: tuple,
                 image: Image.Image) -> int:
     """Draw an image in the overlay at the specified location"""
     pixels = image.convert("RGBA").load()
     w, h = image.size
     l, t, r, b = box
     for x in range(w):
         for y in range(h):
             _x, _y = l + x, t + y
             c = pixels[x, y]
             if c[3] == 0:
                 c = (255, 255, 255)
             else:
                 c = c[:3]
             # print("{} -> {:08x}".format(pixels[x, y], c))
             _c = gui.SetPixel(handle, _x, _y, self._color(c))
             # if _c != c:
             #     print("Requested: {}, Set: {}".format(c, _c))
             # break
     return w
示例#12
0
def draw(i,x,y):
    file = open(i)
    text = file.readlines()
    firstx=x
    for i in text :
        x=firstx
        for j in i :
            print(x,y)
            color = None
            if j == '*' :
                color = 0xff0000
            if j == '@' :
                color = 0x00ff00
            if j == '$' :
                color = 0x0000ff
            if j == '#' :
                color = 0xff00ff
            if color != None :
                for m in range(10):
                    for n in range(10) :
                        win32gui.SetPixel(canvas2,x+m,y+n,color)
            x += 10
        y+=10
示例#13
0
                    continue
                zet = True
                cm.append(i)
        if not zet:
            continue
        zet = False
        if cm:
            im = choice(cm)
        else:
            warn = True
            break

        ps = im[3] if ps != im[3] else im[4]
        mrun.append(im)

    #
    if warn:
        continue

    als = []
    for i in mrun:
        als.append(i[0])
    als = ','.join(als)
    print(als)
    create_grid(grid_mass)
    for ii in mrun:
        for i in ii[1]:
            win32gui.SetPixel(dc, i[0], i[1], win32api.RGB(255, 0, 0))
        sleep(0.07)
    sleep(2)
示例#14
0
def drawdot(x,y):

    win32gui.SetPixel(dc, x, y, white)  # draw red at 0,0
示例#15
0
def set_pixel(x, y, color):  # 설정한 위치의 픽셀을 설정한 색으로 변경하는 함수
    hdc = win32gui.GetDC(win32gui.GetDesktopWindow())
    win32gui.SetPixel(hdc, x, y, color)
示例#16
0
dcObj = win32ui.CreateDCFromHandle(dc)
hwnd = win32gui.WindowFromPoint((0, 0))
monitor = (0, 0, GetSystemMetrics(0), GetSystemMetrics(1))

red = win32api.RGB(255, 0, 0)  # Red

past_coordinates = monitor
while True:
    m = win32gui.GetCursorPos()

    rect = win32gui.CreateRoundRectRgn(*past_coordinates, 2, 2)
    win32gui.RedrawWindow(hwnd, past_coordinates, rect,
                          win32con.RDW_INVALIDATE)

    for x in range(10):
        win32gui.SetPixel(dc, m[0] + x, m[1], red)
        win32gui.SetPixel(dc, m[0] + x, m[1] + 10, red)
        for y in range(10):
            win32gui.SetPixel(dc, m[0], m[1] + y, red)
            win32gui.SetPixel(dc, m[0] + 10, m[1] + y, red)

    past_coordinates = (m[0] - 20, m[1] - 20, m[0] + 20, m[1] + 20)
"""
dc = win32gui.GetDC(0)
dcObj = win32ui.CreateDCFromHandle(dc)
hwnd = win32gui.WindowFromPoint((0,0))
monitor = (0, 0, GetSystemMetrics(0), GetSystemMetrics(1))

m = win32gui.GetCursorPos()

while True:
示例#17
0
dc = win32gui.GetDC(0)
red = win32api.RGB(255, 0, 0)
x, y = pyautogui.position()
if x < firstx:
    tempx, tempy = x, y
    x, y = firstx, firsty
    firstx = tempx
    firsty = tempy
    print("replaced x and y")
try:
    im = PIL.ImageGrab.grab(bbox=(firstx, firsty, x, y))
except:
    im = PIL.ImageGrab.grab(bbox=(x, y, firstx, firsty))
for num1 in range(35):
    for num in range(firsty, y):
        win32gui.SetPixel(dc, firstx - 1, num, red)
        win32gui.SetPixel(dc, firstx - 2, num, red)
        win32gui.SetPixel(dc, x + 1, num, red)
        win32gui.SetPixel(dc, x + 2, num, red)
    for num in range(firstx - 2, x + 2):
        win32gui.SetPixel(dc, num, firsty + 1, red)
        win32gui.SetPixel(dc, num, firsty, red)
        win32gui.SetPixel(dc, num, y, red)
        win32gui.SetPixel(dc, num, y - 1, red)
lang = ""
if second_key == "ctrl":
    lang = "eng"
    print("language: eng")
elif second_key == "shift":
    lang = "heb"
    print("language: hebrew")
示例#18
0
文件: test4.py 项目: jssss93/selenium
import win32api
import win32gui
import win32con
import win32ui

hWnd = win32gui.GetDesktopWindow()
# Retrieves a handle to the desktop window. The desktop window covers the entire screen.
# The desktop window is the area on top of which other windows are painted.
hdc = win32gui.GetDC(hWnd)
#win32gui.GetDC(None)
# A handle to the window whose DC is to be retrieved. If this value is NULL, GetDC
# retrieves the DC for the entire screen.

red = win32api.RGB(255, 0, 0)
win32gui.SetPixel(hdc, 0, 0, red)  # (0, 0)에 빨간 점 그리기

MyPen = win32gui.CreatePen(win32con.PS_SOLID, 5, win32api.RGB(0,0,255));
OldPen = win32gui.SelectObject(hdc, MyPen);

win32gui.Rectangle(hdc, 50, 50, 100, 100) # (50, 50, 100, 100)에 파란 선으로 사각형 그리기

win32gui.SelectObject(hdc, OldPen);
win32gui.DeleteObject(MyPen);

# 폰트 만들기
font_spec = {'name':'Arial', 'height':42, 'weight':30}
font = win32ui.CreateFont(font_spec)
#lf = win32gui.LOGFONT()
#lf.lfFaceName = "Times New Roman"
#lf.lfHeight = 100
#lf.lfWeight = win32con.FW_NORMAL
示例#19
0
def create_grid(grid_mass):
    for i in grid_mass:
        win32gui.SetPixel(dc, i[0], i[1], win32api.RGB(64, 0, 0))
示例#20
0
def climb_to_zero(window):
    v_cursor = (int(window.width / 2), int(window.height / 2))
    start_point = v_cursor

    (r, g, b) = cg.get_pixel_color(v_cursor[0], v_cursor[1])

    while ((r, g, b) == OFFMAPCOLOR):
        win32gui.SetPixel(i_desktop_window_dc, v_cursor[0], v_cursor[1], red)
        v_cursor = (v_cursor[0], v_cursor[1] + 1)
        (r, g, b) = cg.get_pixel_color(v_cursor[0], v_cursor[1])

    (rr, gr, br) = cg.get_pixel_color(v_cursor[0] + 1, v_cursor[1])
    (rd, gd, bd) = cg.get_pixel_color(v_cursor[0] + 1, v_cursor[1] - 1)
    while ((rr, gr, br) != OFFMAPCOLOR or (rd, gd, bd) != OFFMAPCOLOR):
        (rr, gr, br) = cg.get_pixel_color(v_cursor[0] + 1, v_cursor[1])
        (rd, gd, bd) = cg.get_pixel_color(v_cursor[0] + 1, v_cursor[1] - 1)
        win32gui.SetPixel(i_desktop_window_dc, v_cursor[0], v_cursor[1], red)
        v_cursor = (v_cursor[0] + 2, v_cursor[1] - 1)

    v_cursor = (v_cursor[0] - 3, v_cursor[1] + 1)
    tile_center = (v_cursor[0], v_cursor[1] + round(TILE_HEIGHT / 2))

    win32gui.SetPixel(i_desktop_window_dc, tile_center[0], tile_center[1],
                      win32api.RGB(0, 255, 0))
    win32gui.SetPixel(i_desktop_window_dc, tile_center[0] - TILE_WIDTH,
                      tile_center[1] + TILE_HEIGHT, win32api.RGB(0, 255, 0))
    win32gui.SetPixel(i_desktop_window_dc, tile_center[0] + TILE_WIDTH,
                      tile_center[1] + TILE_HEIGHT, win32api.RGB(0, 255, 0))
    win32gui.SetPixel(i_desktop_window_dc, tile_center[0],
                      tile_center[1] + TILE_HEIGHT, win32api.RGB(0, 255, 0))
    win32gui.SetPixel(i_desktop_window_dc,
                      tile_center[0], tile_center[1] + TILE_HEIGHT * 2,
                      win32api.RGB(0, 255, 0))
    win32gui.SetPixel(i_desktop_window_dc,
                      tile_center[0] + round(TILE_WIDTH / 2),
                      tile_center[1] + round(TILE_HEIGHT / 2),
                      win32api.RGB(0, 255, 0))
    win32gui.SetPixel(i_desktop_window_dc,
                      tile_center[0] - round(TILE_WIDTH / 2),
                      tile_center[1] + round(TILE_HEIGHT / 2),
                      win32api.RGB(0, 255, 0))
    win32gui.SetPixel(i_desktop_window_dc,
                      tile_center[0] + round(TILE_WIDTH / 2),
                      tile_center[1] + TILE_HEIGHT + round(TILE_HEIGHT / 2),
                      win32api.RGB(0, 255, 0))
    win32gui.SetPixel(i_desktop_window_dc,
                      tile_center[0] - round(TILE_WIDTH / 2),
                      tile_center[1] + TILE_HEIGHT + round(TILE_HEIGHT / 2),
                      win32api.RGB(0, 255, 0))
示例#21
0
def setPixel(x, y, color):
    hdc = win32gui.GetDC(win32gui.GetDesktopWindow())
    win32gui.SetPixel(hdc, x, y, color)
示例#22
0
def draw(x, y):
    win = win32gui.GetForegroundWindow()
    dc = win32gui.GetWindowDC(win)
    win32gui.SetPixel(dc, x, y, RGB(255, 255, 255))
    win32gui.ReleaseDC(win, dc)