Last active
April 29, 2022 01:40
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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% | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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