Skip to content

Instantly share code, notes, and snippets.

@Crozzers
Crozzers / IsWindowArranged.py
Created June 8, 2024 15:49
Short snippet for exposing the IsWindowArranged win32 function in Python
import win32api
import ctypes
user32 = win32api.LoadLibrary('User32.dll')
# IsWindowArranged doesn't have a header file, so I assume that's why it's not exposed in win32api (py version).
# We can still access that function by getting it's address with ctypes.
# See https://learn.microsoft.com/en-us/windows/win32/winmsg/winuser/nf-winuser-iswindowarranged#remarks
# get function address
# Sources:
# https://stackoverflow.com/questions/69712306/list-all-windows-with-win32gui
# http://timgolden.me.uk/pywin32-docs/win32gui__GetWindowRect_meth.html
# http://timgolden.me.uk/pywin32-docs/win32gui__MoveWindow_meth.html
# Todo:
# https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-settingchange
# https://stackoverflow.com/questions/5981520/detect-external-display-being-connected-or-removed-under-windows-7
import win32gui
import time
@Crozzers
Crozzers / scrollable_tk_frame.py
Last active June 8, 2024 15:50
A scrollable frame class in tkinter.
import platform
import tkinter as tk
from typing import Union
class ScrollableFrame(tk.Frame):
'''
A class used to create a *mostly* tkinter compatible frame that is scrollable.
It works by creating a master frame which contains a canvas and scrollbar(s).