#Requires AutoHotkey v2.0 #SingleInstance force SetTitleMatchMode(3) SW := A_ScreenWidth SH := A_ScreenHeight Global Stretched := false Global CursorLocked := false Global CursorWasLockedBeforeFocusLoss := false Global CursorAutoMode := true Global GameWatcherRunning := false ; AutoHotkey script to make Path of Exile borderless windowed ;###Settings##################################################################################### ; Hotkey to trigger the resizing (you can change to any key you prefer) ; ^ = ctrl, + = shift, ! = alt more info about hotkeys can be found at https://www.autohotkey.com/docs/v1/Hotkeys.htm Hotkey "^NumPad0", ToggleBoarderlessStretch Hotkey "^NumPad5", ToggleAlwaysOnTop Hotkey "^NumPad3", ToggleCursorLock ; Set the desired width and height for the borderless window AutoH := SH/1.35 ; 1.35 is the default zoom modifiar. If you get black bars on your game's sides, put it lower start at 1.30, save & reload script till satisfied DesiredWidth := SW ; Change to desirerd Width of the gaming window, Accepted Values: Value in Pixels, SW for Same Width as monitor DesiredHeight := AutoH ; Change to desirerd Hight of the gaming window, Accepted Values: Value in Pixels, SH for Same Height as monitor, AutoH for Automatic stretched windowed ; Set desired window location X := (SW - DesiredWidth)/2 ; Set the desirerd X location of the gaming window, Accepted Values: Value in Pixels 0 being all way left, (SW - DesiredWidth)/2 for automatic center Y := 0 ; Set the desirerd Y location of the gaming window, Accepted Values: Value in Pixels 0 being all way top, (SH - DesiredHeight)/2 for automatic center, (SH - DesiredHeight) for all way at bottom ; Game name, change as necessary GameTitle := "Path of Exile" GameExe := "PathOfExile.exe" ;############################################################################################# SetTimer(CheckWindowFocus, 200) ; Check window focus 5 times per second ToggleAlwaysOnTop(ThisHotkey){ ; Check if the game window is open if WinExist(GameTitle){ ; Activate the game window found by WinExist WinActivate ; Remove the borders and title bar ; 0xC40000 = WS_BORDER (0x800000) + WS_DLGFRAME (0x400000) + WS_SIZEBOX aka WS_THICKFRAME (0x040000) WinSetAlwaysOnTop -1, GameTitle } else{ MsgBox "Please launch game first.", "Game not found" } } ToggleBoarderlessStretch(ThisHotkey){ Global Stretched ; Check if the game window is open if WinExist(GameTitle){ ; Activate the game window found by WinExist WinActivate ;Check if already stretched windowed if !Stretched { Stretched := true ; Remove the borders and title bar ; 0xC40000 = WS_BORDER (0x800000) + WS_DLGFRAME (0x400000) + WS_SIZEBOX aka WS_THICKFRAME (0x040000) WinSetStyle("-0xC40000", GameTitle) ; Resize the window to borderless dimensions WinMove X, Y, DesiredWidth, DesiredHeight, GameTitle ; Else we return to original resolution }else{ Stretched := false WinSetStyle("-0xC40000", GameTitle) WinMove 0, 0, SW, SH, GameTitle } ; Reapply cursor lock if active if CursorLocked { WinGetPos &winX, &winY, &winW, &winH, GameTitle rect := Buffer(16, 0) NumPut("Int", winX, rect, 0) NumPut("Int", winY, rect, 4) NumPut("Int", winX + winW, rect, 8) NumPut("Int", winY + winH, rect, 12) DllCall("ClipCursor", "Ptr", rect) } ;ExitApp } else{ MsgBox "Please launch game first.", "Game not found" } } ToggleCursorLock(ThisHotkey) { Global CursorLocked, CursorAutoMode if CursorLocked { DllCall("ClipCursor", "Ptr", 0) CursorLocked := false CursorAutoMode := false ; prevent auto-relock ToolTip "Cursor Unlocked" } else { if WinExist(GameTitle) { WinGetPos &winX, &winY, &winW, &winH, GameTitle rect := Buffer(16, 0) NumPut("Int", winX, rect, 0) NumPut("Int", winY, rect, 4) NumPut("Int", winX + winW, rect, 8) NumPut("Int", winY + winH, rect, 12) DllCall("ClipCursor", "Ptr", rect) CursorLocked := true CursorAutoMode := true ; allow auto-relock ToolTip "Cursor Locked" } else { MsgBox "Game not found.", "Error" } } SetTimer () => ToolTip(), -1000 } CheckWindowFocus() { Global CursorLocked, CursorWasLockedBeforeFocusLoss, CursorAutoMode, Stretched Global GameTitle, GameExe hwnd := WinExist(GameTitle) if !hwnd || WinGetProcessName(hwnd) != GameExe { Stretched := false if CursorLocked { DllCall("ClipCursor", "Ptr", 0) CursorLocked := false CursorWasLockedBeforeFocusLoss := false CursorAutoMode := true ToolTip "Game closed — cursor unlocked" SetTimer () => ToolTip(), -1000 } ; Stop this timer, but ensure game watcher is running SetTimer(CheckWindowFocus, 0) StartGameWatcher() return } ; Game is running, handle cursor lock if WinActive(GameTitle) { if !CursorLocked && CursorWasLockedBeforeFocusLoss && CursorAutoMode { WinGetPos &winX, &winY, &winW, &winH, GameTitle rect := Buffer(16, 0) NumPut("Int", winX, rect, 0) NumPut("Int", winY, rect, 4) NumPut("Int", winX + winW, rect, 8) NumPut("Int", winY + winH, rect, 12) DllCall("ClipCursor", "Ptr", rect) CursorLocked := true CursorWasLockedBeforeFocusLoss := false ToolTip "Cursor re-locked" SetTimer () => ToolTip(), -1000 } } else if CursorLocked { DllCall("ClipCursor", "Ptr", 0) CursorWasLockedBeforeFocusLoss := true CursorLocked := false ToolTip "Cursor auto-unlocked (focus lost)" SetTimer () => ToolTip(), -1000 } } StartGameWatcher() { Global GameWatcherRunning if !GameWatcherRunning { SetTimer(CheckGameRunning, 2000) GameWatcherRunning := true } } CheckGameRunning() { Global GameTitle, GameExe, GameWatcherRunning hwnd := WinExist(GameTitle) if hwnd && WinGetProcessName(hwnd) = GameExe { SetTimer(CheckWindowFocus, 200) SetTimer(CheckGameRunning, 0) GameWatcherRunning := false ToolTip "Game relaunched — cursor tracking re-enabled" SetTimer () => ToolTip(), -1000 } }