Skip to content

Instantly share code, notes, and snippets.

@zero-plusplus
Last active April 29, 2022 01:40
Show Gist options
  • Save zero-plusplus/89b5278de42d903ce2abf53e4da5433b to your computer and use it in GitHub Desktop.
Save zero-plusplus/89b5278de42d903ce2abf53e4da5433b to your computer and use it in GitHub Desktop.
Function that works with AutoHotkey v1 or v2 to set a window to pseudo fullscreen.
/**
* @author zero-plusplus (https://github.com/zero-plusplus)
* @licence MIT
* @link https://gist.github.com/zero-plusplus/89b5278de42d903ce2abf53e4da5433b
*/
/**
* !!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* This function is intended for use in single games without an anti-cheat system.
* AutoHotkey may be treated as a cheat by anti-cheat systems and may result in a ban in the worst case. Never use it.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* Hides the window title bar and expands the window to fill the screen. i.e. pseudo full screen.
* @param {number} [hwnd] - Target window handle. If omitted, the active window is targeted.
* @example
* SetPseudoFullScreen(WinExist("ahk_class Notepad"))
*/
SetPseudoFullScreen(hwnd := "") {
if (hwnd == 0) {
throw Exception("Window not found.")
}
if (hwnd == "") {
hwnd := WinActive("A")
}
; https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos
DllCall("SetWindowPos"
, "UInt", hwnd
, "UInt", hWndInsertAfter := 0
, "Int", x := -2
, "Int", y := -2
, "Int", cx := A_ScreenWidth + 4
, "Int", cy := A_ScreenHeight + 4
, "UInt", uFlags := 0)
WinSet, Style, -0xC00000, ahk_id %hwnd%
}
/**
* @author zero-plusplus (https://github.com/zero-plusplus)
* @licence MIT
* @link https://gist.github.com/zero-plusplus/89b5278de42d903ce2abf53e4da5433b
*/
/**
* !!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* This function is intended for use in single games without an anti-cheat system.
* AutoHotkey may be treated as a cheat by anti-cheat systems and may result in a ban in the worst case. Never use it.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* Hides the window title bar and expands the window to fill the screen. i.e. pseudo full screen.
* @param {number} [hwnd] - Target window handle. If omitted, the active window is targeted.
* @example
* SetPseudoFullScreen(WinExist("ahk_class Notepad"))
*/
SetPseudoFullScreen(hwnd := "") {
if (hwnd == 0) {
throw Error("Window not found.")
}
if (hwnd == "") {
hwnd := WinActive("A")
}
; https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos
DllCall(
"SetWindowPos",
"UInt", hwnd,
"UInt", hWndInsertAfter := 0,
"Int", x := -2,
"Int", y := -2,
"Int", cx := A_ScreenWidth + 4,
"Int", cy := A_ScreenHeight + 4,
"UInt", uFlags := 0,
)
WinSetStyle("-0xC00000", "ahk_id" hwnd)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment