Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Persistent ; Keep the script running
- ; Check every second if Baldur.exe is still running
- SetTimer, CheckProcess, 5000
- SetTitleMatchMode, 2 ; Set matching mode for window titles
- SetTimer, CheckGameWindow, 1000 ; Check every second
- return
- CheckGameWindow:
- ; Look for the game window by its class name
- IfWinExist, ahk_class SDL_app ; SDL_app is the window class for Baldur.exe
- {
- ; Get the window's handle
- WinGet, gameWindow, ID, ahk_class SDL_app
- ; Get the process name for the window (i.e., executable name)
- WinGet, ProcessName, ProcessName, ahk_id %gameWindow%
- ; Only proceed if the executable is Baldur.exe
- If (ProcessName = "Baldur.exe")
- {
- ; Remove the title bar and borders to make it borderless
- WinSet, Style, -0xC00000, ahk_id %gameWindow%
- ; Get the screen dimensions of the primary monitor
- ScreenWidth := A_ScreenWidth
- ScreenHeight := A_ScreenHeight
- ; Move the top-left corner of the window for Baldur's Gate to X=-7,Y=-7 and make it take up the entire screen space of the primary 1440p monitor
- ; WinMove, WinTitle, , WinText (Blank), X Position, Y Position, Screen Width+Offset, Screen Height+Offset
- WinMove, ahk_id %gameWindow%, , -7, -7, 2560+14, 1440+14
- ; For some reason the WinMove function causes the window for Baldur.exe to be rendered with 7 pixels of empty space on all sides.
- ; Adding 14 pixels to the screen width and height and then setting an offset of -7 pixels solves this issue on my screen.
- ; You may need to find different values for these.
- }
- }
- return
- CheckProcess:
- ; Check if Baldur's Gate: Enhanced Edition is still running
- if !ProcessExist("Baldur.exe") {
- ExitApp ; Terminate the script if Baldur.exe is not running
- }
- Return
- ; Function to check if a process is running
- ProcessExist(ProcessName) {
- Process, Exist, %ProcessName%
- return ErrorLevel ; Returns non-zero if process exists
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement