Help with v2 script to toggle between fullscreen and windowed modes
Posted: 19 Nov 2023, 11:24
Hello, I was helped with converting a script from v1 to v2 earlier, but it's still not fully functional yet. Could someone help me to get it working please, as I'm not experienced with AHK.
It's supposed to toggle between fullscreen and windowed modes of an application when pressing F12, as well as hide the taskbar during the fullscreen mode. I need it to work with a multi-monitor setup. What happens right now is, it just toggles a white border around the active application when I press F12, and It also only has any sort of effect on my main screen. When I try it on an application on my second monitor, the active window disappears from view completely on the second monitor, and the taskbar disappears on the first monitor. Any help would be very appreciated, and thank you in advance.
It's supposed to toggle between fullscreen and windowed modes of an application when pressing F12, as well as hide the taskbar during the fullscreen mode. I need it to work with a multi-monitor setup. What happens right now is, it just toggles a white border around the active application when I press F12, and It also only has any sort of effect on my main screen. When I try it on an application on my second monitor, the active window disappears from view completely on the second monitor, and the taskbar disappears on the first monitor. Any help would be very appreciated, and thank you in advance.
Code: Select all
#Requires AutoHotkey v2.0
; Toggle between fullscreen and windowed modes when pressing F12 as well as hide the taskbar during the fullscreen mode
F12::{
static windowId := "", winPosX, winPosY, windowWidth, windowHeight, windowState := ""
tempWindowId := WinExist("A")
if (windowId != tempWindowId) {
windowId := tempWindowId
windowState := 0
}
if (windowState != 1) {
WinGetPos &winPosX, &winPosY, &windowWidth, &windowHeight, windowId
WinSetStyle "-0xC40000", windowId
WinMove 0, 0, A_ScreenWidth, A_ScreenHeight, windowId
;Hide Windows Task Bar and Start Button. (Remove the following two lines if you don't want that behaviour)
try WinHide "ahk_class Shell_TrayWnd"
try WinHide "Start ahk_class Button"
} else {
WinSetStyle "+0xC40000", windowId
WinMove winPosX, winPosY, windowWidth, windowHeight, windowId
;Show the task bar again
try WinShow "ahk_class Shell_TrayWnd"
try WinShow "Start ahk_class Button"
}
windowState := !windowState
}