Skip to content

Instantly share code, notes, and snippets.

@CostaFot
Last active April 5, 2026 21:10
Show Gist options
  • Select an option

  • Save CostaFot/0b5209ccca91cef7cfabeeac804529c1 to your computer and use it in GitHub Desktop.

Select an option

Save CostaFot/0b5209ccca91cef7cfabeeac804529c1 to your computer and use it in GitHub Desktop.
// Define which Windows functions we need
internal interface User32 : Library {
fun FindWindowA(className: String?, windowTitle: String?): Pointer?
fun GetWindowLongA(hwnd: Pointer, index: Int): Int
fun SetWindowLongA(hwnd: Pointer, index: Int, newStyle: Int): Int
}
class WindowsWindowStyleHelper : WindowStyleHelper {
// JNA loads the actual Windows DLL at runtime
val user32 = Native.load("user32", User32::class.java)
override fun hideFromTaskbar(windowTitle: String) {
val hwnd = user32.FindWindowA(null, windowTitle) ?: return
val style = user32.GetWindowLongA(hwnd, GWL_EXSTYLE)
user32.SetWindowLongA(hwnd, GWL_EXSTYLE,
(style or WS_EX_TOOLWINDOW) and WS_EX_APPWINDOW.inv()
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment