윈도우 화면 반전 프로그램(윈도우 화면 다크모드)
한글 이나 기타 pdf로 말린 보고서를 보다보면 눈이 너무 아픕니다.
한글 다크모드가 없어서 어떻게 할까하다가 화면 자체를 반전하여 만드는 방법이 있었습니다. 그런데 이건 너무 불편해서 프로그램을 찾다가
gemini에게 요청하니깐 금방 만들어주네요..
단순 흑백반전이 눈아프다니깐 회색으로 해줍니다.
파이썬 코드는 다음과 같습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | import ctypes import tkinter as tk from tkinter import messagebox, simpledialog import keyboard import atexit import sys # ============================================================================== # Windows API 및 색상 매트릭스 설정 # ============================================================================== # Windows API 함수 정의 try: ctypes.windll.shcore.SetProcessDpiAwareness(1) except (AttributeError, OSError): pass # DPI 인식 설정은 Windows 8.1 이상에서만 가능 MagInitialize = ctypes.windll.magnification.MagInitialize MagUninitialize = ctypes.windll.magnification.MagUninitialize SetMagnificationFullscreenColorEffect = ctypes.windll.magnification.MagSetFullscreenColorEffect # 색상 변환 행렬 # 반전된 회색조 color_matrix_inverted = ( -0.3, -0.3, -0.3, 0.0, 0.0, -0.6, -0.6, -0.6, 0.0, 0.0, -0.1, -0.1, -0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0 ) # 기본 색상 (반전 없음) color_matrix_normal = ( 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 ) # ============================================================================== # 핵심 기능 클래스 # ============================================================================== class ScreenInverterApp: def __init__(self, root): self.root = root self.is_inverted = False self.hotkey = 'ctrl+alt+i' self.setup_core() self.setup_gui() self.setup_hotkey() def setup_core(self): """API 초기화 및 종료 시 정리 작업 설정""" MagInitialize() atexit.register(self.cleanup) def setup_gui(self): """GUI 요소 설정""" self.root.title("Invert") self.root.geometry("50x50-30-30") self.root.overrideredirect(True) self.root.attributes("-topmost", True) self.button = tk.Button(self.root, text="👁️", command=self.toggle_inversion, font=("Segoe UI Emoji", 12), relief="flat", bg="white") self.button.pack(expand=True, fill="both") self.setup_menu() def setup_menu(self): """우클릭 메뉴 설정""" self.menu = tk.Menu(self.root, tearoff=0) self.menu.add_command(label="단축키 편집", command=self.edit_hotkey) self.menu.add_separator() self.menu.add_command(label="만든사람", command=self.show_about) self.menu.add_command(label="종료", command=self.quit_app) self.root.bind("<Button-3>", self.show_popup_menu) def setup_hotkey(self): """키보드 단축키 설정""" try: keyboard.add_hotkey(self.hotkey, self.toggle_inversion) except Exception as e: messagebox.showerror("오류", f"단축키 설정에 실패했습니다: {e}") def toggle_inversion(self): """화면 색상 반전 상태를 토글""" self.is_inverted = not self.is_inverted effect = color_matrix_inverted if self.is_inverted else color_matrix_normal SetMagnificationFullscreenColorEffect((ctypes.c_float * 25)(*effect)) def edit_hotkey(self): """단축키 편집 기능 (현재는 플레이스홀더)""" new_hotkey = simpledialog.askstring("단축키 편집", f"새로운 단축키를 입력하세요 (현재: {self.hotkey})", parent=self.root) if new_hotkey: try: keyboard.remove_hotkey(self.hotkey) self.hotkey = new_hotkey.lower() self.setup_hotkey() messagebox.showinfo("성공", f"단축키가 '{self.hotkey}'로 변경되었습니다.") except Exception as e: messagebox.showerror("오류", f"단축키 변경에 실패했습니다: {e}") # 실패 시 이전 단축키로 복구 self.setup_hotkey() def show_about(self): """'만든사람' 정보 표시""" messagebox.showinfo("만든사람", """이 프로그램은 baru에 의해 만들어졌습니다. 만든 날짜: 2025년 7월 25일""", parent=self.root) def show_popup_menu(self, event): """우클릭 시 메뉴 표시""" try: self.menu.tk_popup(event.x_root, event.y_root) finally: self.menu.grab_release() def cleanup(self): """프로그램 종료 시 화면을 원래 상태로 복원""" if self.is_inverted: SetMagnificationFullscreenColorEffect((ctypes.c_float * 25)(*color_matrix_normal)) MagUninitialize() def quit_app(self): """어플리케이션 종료""" self.root.quit() # ============================================================================== # 프로그램 실행 # ============================================================================== if __name__ == "__main__": root = tk.Tk() app = ScreenInverterApp(root) root.mainloop() | cs |
exe 파일은 다음과 같습니다.
https://drive.google.com/file/d/1rOyE64-GPixMlniEGNRkljb1xUcVYjnE/view?usp=sharing
화면 오른쪽 아래에 눈이 생깁니다.
이를 클릭하면 흑백반전
다시 클릭하면 원상복귀합니다.
댓글
댓글 쓰기