Last active
May 24, 2025 07:01
-
-
Save kulvind3r/046332894cbb38850f26597532eef5e6 to your computer and use it in GitHub Desktop.
Mist: A browser overlay for non steam games built using AutoHotKey v2.0. Opens your installed browser for looking up guides, walkthroughs, maps or anyting else you want.
This file contains hidden or 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
| ; Mist: A browser overlay for non steam games. | |
| browserPath := "C:\Program Files\Mozilla Firefox\firefox.exe" ; replace with browser of your choice | |
| browserExe := "firefox.exe" ; exe of the browser in above line | |
| browserWidth := 1600 ; Horizontal size of browser you will like. Must be less than max horizontal resolution of primary monitor | |
| browserHeight := 900 ; Vertical size of browser you will like. Must be less than max horizontal resolution of primary monitor | |
| !Space:: ; Default hotkey is Alt + Space | |
| { | |
| ; Toggle the overlay and browser | |
| if WinExist("Dark Overlay") | |
| { | |
| ActiveWindow := "" | |
| if FileExist("last_active_window.txt") | |
| ActiveWindow := FileRead("last_active_window.txt") | |
| if WinExist("ahk_exe " browserExe) | |
| WinMinimize("ahk_exe " browserExe) | |
| WinClose("Dark Overlay") | |
| FileDelete "last_active_window.txt" | |
| ; If there was an active window before overlay was enabled, restore it | |
| if (ActiveWindow != "") | |
| WinRestore ActiveWindow | |
| } | |
| else | |
| { | |
| ; Capture title of actively running window, can be empty if no window is focused | |
| ActiveWindow := WinGetTitle("A") | |
| FileAppend ActiveWindow, "last_active_window.txt" | |
| ; Create the dark overlay | |
| darkOverlay:= Gui() | |
| darkOverlay.BackColor := "Black" | |
| darkOverlay.Opt("+AlwaysOnTop -Caption +Disabled +ToolWindow") | |
| darkOverlay.Title := "Dark Overlay" | |
| WinSetTransparent(150, darkOverlay.Hwnd) | |
| ; Show the overlay | |
| darkOverlay.Show("x0 y0 w" A_ScreenWidth " h" A_ScreenHeight " NoActivate") | |
| WinSetAlwaysOnTop 0, "Dark Overlay" | |
| ; Launch Browser | |
| if !WinExist("ahk_exe " browserExe) | |
| { | |
| Run(browserPath) | |
| WinWait("ahk_exe " browserExe) | |
| ; Firefox does a window size restore after finishing loading new tab page or pinned tabs. | |
| ; We need to wait for this auto resize to finish before resizing the browser for overlay. | |
| ; If browser is not correctly sized for overlay, try increasing below sleep value to 1500, 2000 etc. | |
| Sleep(750) | |
| } | |
| ; Activate and position Browser | |
| if WinExist("ahk_exe " browserExe) | |
| { | |
| WinRestore("ahk_exe " browserExe) | |
| WinMove((A_ScreenWidth - browserWidth)/2, (A_ScreenHeight - browserHeight)/2, browserWidth, browserHeight, ("ahk_exe " browserExe)) | |
| WinMoveTop("ahk_exe " browserExe) | |
| WinActivate("ahk_exe " browserExe) | |
| } | |
| ; Activate timer to watch and close the overlay if browser is closed | |
| SetTimer monitorBrowser, 250 | |
| monitorBrowser() | |
| { | |
| ; Turn off the timer if the file has been deleted due to overlay being toggled off using hotkey | |
| if !FileExist("last_active_window.txt") | |
| SetTimer , 0 | |
| if !WinExist("ahk_exe " browserExe) | |
| { | |
| darkOverlay.Destroy() | |
| SetTimer , 0 ; Turn off the timer | |
| FileDelete "last_active_window.txt" | |
| ; If there was an active window before overlay was enabled, restore it | |
| if (ActiveWindow != "") | |
| WinRestore ActiveWindow | |
| } | |
| } | |
| } | |
| } | |
| ; End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment