1
$\begingroup$

I was wondering for my addon how to resize, move, and modify the always on top status of the active window.

$\endgroup$

1 Answer 1

3
$\begingroup$
import ctypes
from ctypes import wintypes

#Get Active  #https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getactivewindow
#Set win     #https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setwindowpos

#SetWindowPos FUNCTION
SetWindowPos = ctypes.windll.user32.SetWindowPos
SetWindowPos.restype = wintypes.BOOL
SetWindowPos.argtypes = [
    wintypes.HWND, #hWnd
    wintypes.HWND, #hWndInsertAfter
    ctypes.c_int,  #X #pos
    ctypes.c_int,  #Y #pos
    ctypes.c_int,  #cx #new width
    ctypes.c_int,  #cy #new height
    ctypes.c_uint, #uFlags
]
#HANDLE
Active_W = ctypes.windll.user32.GetActiveWindow()

#FLAGS
SWP_HIDEWINDOW = 0x80 #HIDE 
SWP_SHOWWINDOW = 0x40 #SHOW
SWP_NOMOVE     = 0x0002 #NO MOVE
SWP_NOSIZE     = 0x0001 #NO SIZE


#EXAMPLE ON TOP -> because -> -1
#SetWindowPos(Active_W, -1, 0, 0, 0, 0,SWP_NOMOVE|SWP_NOSIZE )

#EXAMPLE ON TOP CANCEL -> because -> -2
#SetWindowPos(Active_W, -2, 0, 0, 0, 0,SWP_NOMOVE|SWP_NOSIZE )

#EXEMPLE DEPLACE     
#SetWindowPos(Active_W, 0, 2550, 0, 0, 0, SWP_NOSIZE )

#EXEMPLE RESIZE #column size
#SetWindowPos(Active_W, 0, 0, 0, 100, 1000, SWP_NOMOVE)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .