INNER CODE UNIT · Python

get_scale_factor

Qwejay/Qflow · main.py:74

def get_scale_factor():
    try:
        if sys.platform.startswith('win'):
            try: shcore.SetProcessDpiAwareness(1)
            except: user32.SetProcessDPIAware()
        log_w, log_h = pyautogui.size()
        phy_w, phy_h = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
        if log_w == 0 or phy_w == 0: return 1.0, 1.0
        return max(0.5, min(4.0, phy_w / log_w)), max(0.5, min(4.0, phy_h / log_h))
    except: return 1.0, 1.0

SCALE_X, SCALE_Y = get_scale_factor()
SCALE_FACTOR = (SCALE_X + SCALE_Y) / 2.0
Box = namedtuple('Box', 'left top width height')

def safe_float(value, default=0.0):
    try: return float(value)
    except (ValueError, TypeError): return default

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…