实时取色器(RGB)

发布时间:2025-12-09 22:14:07 浏览次数:4

 能够实时显示鼠标所在位置的RBG(带弹窗),便于实时取色,创作不易,喜欢的话麻烦点赞收藏哟~

# -*- coding: utf-8 -*-import pyautogui, sysfrom ctypes import * # 获取屏幕上某个坐标的颜色def GetColor():r = 0g = 0b = 0try:x, y = pyautogui.position()gdi32 = windll.gdi32user32 = windll.user32hdc = user32.GetDC(None) # 获取颜色值pixel = gdi32.GetPixel(hdc, x, y) # 提取RGB值r = pixel & 0x0000ffg = (pixel & 0x00ff00) >> 8b = pixel >> 16except KeyboardInterrupt:print('\n')return r,g,bimport tkinter as tkwindow = tk.Tk()window.wm_attributes('-topmost', 1)window.title('小白取色器')window.geometry('200x100')a = tk.StringVar()l = tk.Label(window, textvariable=a, # 标签的文字bg='green', # 标签背景颜色font=('Arial', 12), # 字体和字体大小width=15, height=2 # 标签长宽(以字符长度计算))l.pack() # 固定窗口位置while 1:r,g,b = GetColor()print(str(r) + ',' + str(g) + ',' + str(b))a.set(str(r)+','+str(g)+','+str(b))l.update()window.mainloop()

 另外我写了一篇能够获取鼠标实时位置(带弹窗)的博客:(48条消息) 实时获取鼠标位置_晋升阁的博客-CSDN博客

欢迎来踩!!!

需要做网站?需要网络推广?欢迎咨询客户经理 13272073477