Advertisement
BourbonCrow

Path of Exile (PoE) Borderless Stretched (Using Hotkey)

Feb 28th, 2025 (edited)
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Requires AutoHotkey v2.0
  2. #SingleInstance force
  3. SetTitleMatchMode(3)
  4. SW := A_ScreenWidth
  5. SH := A_ScreenHeight
  6. Global Stretched := false
  7. Global CursorLocked := false
  8. Global CursorWasLockedBeforeFocusLoss := false
  9. Global CursorAutoMode := true
  10. Global GameWatcherRunning := false
  11.  
  12.  
  13. ; AutoHotkey script to make Path of Exile borderless windowed
  14.  
  15. ;###Settings#####################################################################################
  16.  
  17. ; Hotkey to trigger the resizing (you can change to any key you prefer)
  18. ; ^ = ctrl, + = shift, ! = alt more info about hotkeys can be found at https://www.autohotkey.com/docs/v1/Hotkeys.htm
  19. Hotkey "^NumPad0", ToggleBoarderlessStretch
  20. Hotkey "^NumPad5", ToggleAlwaysOnTop
  21. Hotkey "^NumPad3", ToggleCursorLock
  22.  
  23. ; Set the desired width and height for the borderless window
  24. 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
  25. DesiredWidth := SW ; Change to desirerd Width of the gaming window, Accepted Values: Value in Pixels, SW for Same Width as monitor
  26. 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
  27.  
  28.  
  29. ; Set desired window location
  30. 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
  31. 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
  32.  
  33. ; Game name, change as necessary
  34. GameTitle := "Path of Exile"
  35. GameExe := "PathOfExile.exe"
  36.  
  37. ;#############################################################################################
  38.  
  39. SetTimer(CheckWindowFocus, 200) ; Check window focus 5 times per second
  40.  
  41.  
  42. ToggleAlwaysOnTop(ThisHotkey){
  43.     ; Check if the game window is open
  44.     if WinExist(GameTitle){
  45.         ; Activate the game window found by WinExist
  46.         WinActivate
  47.  
  48.         ; Remove the borders and title bar
  49.         ; 0xC40000 = WS_BORDER (0x800000) + WS_DLGFRAME (0x400000) + WS_SIZEBOX aka WS_THICKFRAME (0x040000)
  50.         WinSetAlwaysOnTop -1, GameTitle
  51.     }
  52.     else{
  53.         MsgBox "Please launch game first.", "Game not found"
  54.     }
  55. }
  56.  
  57. ToggleBoarderlessStretch(ThisHotkey){
  58.     Global Stretched
  59.     ; Check if the game window is open
  60.     if WinExist(GameTitle){
  61.         ; Activate the game window found by WinExist
  62.         WinActivate
  63.         ;Check if already stretched windowed
  64.         if !Stretched {
  65.             Stretched := true
  66.             ; Remove the borders and title bar
  67.             ; 0xC40000 = WS_BORDER (0x800000) + WS_DLGFRAME (0x400000) + WS_SIZEBOX aka WS_THICKFRAME (0x040000)
  68.             WinSetStyle("-0xC40000", GameTitle)
  69.             ; Resize the window to borderless dimensions
  70.             WinMove X, Y, DesiredWidth, DesiredHeight, GameTitle
  71.             ; Else we return to original resolution
  72.         }else{
  73.             Stretched := false
  74.             WinSetStyle("-0xC40000", GameTitle)
  75.             WinMove 0, 0, SW, SH, GameTitle
  76.         }
  77.         ; Reapply cursor lock if active
  78.         if CursorLocked {
  79.             WinGetPos &winX, &winY, &winW, &winH, GameTitle
  80.             rect := Buffer(16, 0)
  81.             NumPut("Int", winX, rect, 0)
  82.             NumPut("Int", winY, rect, 4)
  83.             NumPut("Int", winX + winW, rect, 8)
  84.             NumPut("Int", winY + winH, rect, 12)
  85.             DllCall("ClipCursor", "Ptr", rect)
  86.         }
  87.         ;ExitApp
  88.     }
  89.     else{
  90.         MsgBox "Please launch game first.", "Game not found"
  91.     }
  92. }
  93.  
  94. ToggleCursorLock(ThisHotkey) {
  95.     Global CursorLocked, CursorAutoMode
  96.  
  97.     if CursorLocked {
  98.         DllCall("ClipCursor", "Ptr", 0)
  99.         CursorLocked := false
  100.         CursorAutoMode := false ; prevent auto-relock
  101.         ToolTip "Cursor Unlocked"
  102.     } else {
  103.         if WinExist(GameTitle) {
  104.             WinGetPos &winX, &winY, &winW, &winH, GameTitle
  105.  
  106.             rect := Buffer(16, 0)
  107.             NumPut("Int", winX, rect, 0)
  108.             NumPut("Int", winY, rect, 4)
  109.             NumPut("Int", winX + winW, rect, 8)
  110.             NumPut("Int", winY + winH, rect, 12)
  111.             DllCall("ClipCursor", "Ptr", rect)
  112.  
  113.             CursorLocked := true
  114.             CursorAutoMode := true ; allow auto-relock
  115.             ToolTip "Cursor Locked"
  116.         } else {
  117.             MsgBox "Game not found.", "Error"
  118.         }
  119.     }
  120.  
  121.     SetTimer () => ToolTip(), -1000
  122. }
  123.  
  124. CheckWindowFocus() {
  125.     Global CursorLocked, CursorWasLockedBeforeFocusLoss, CursorAutoMode, Stretched
  126.     Global GameTitle, GameExe
  127.  
  128.     hwnd := WinExist(GameTitle)
  129.     if !hwnd || WinGetProcessName(hwnd) != GameExe {
  130.         Stretched := false
  131.         if CursorLocked {
  132.             DllCall("ClipCursor", "Ptr", 0)
  133.             CursorLocked := false
  134.             CursorWasLockedBeforeFocusLoss := false
  135.             CursorAutoMode := true
  136.             ToolTip "Game closed — cursor unlocked"
  137.             SetTimer () => ToolTip(), -1000
  138.         }
  139.  
  140.         ; Stop this timer, but ensure game watcher is running
  141.         SetTimer(CheckWindowFocus, 0)
  142.         StartGameWatcher()
  143.         return
  144.     }
  145.  
  146.     ; Game is running, handle cursor lock
  147.     if WinActive(GameTitle) {
  148.         if !CursorLocked && CursorWasLockedBeforeFocusLoss && CursorAutoMode {
  149.             WinGetPos &winX, &winY, &winW, &winH, GameTitle
  150.             rect := Buffer(16, 0)
  151.             NumPut("Int", winX, rect, 0)
  152.             NumPut("Int", winY, rect, 4)
  153.             NumPut("Int", winX + winW, rect, 8)
  154.             NumPut("Int", winY + winH, rect, 12)
  155.             DllCall("ClipCursor", "Ptr", rect)
  156.             CursorLocked := true
  157.             CursorWasLockedBeforeFocusLoss := false
  158.             ToolTip "Cursor re-locked"
  159.             SetTimer () => ToolTip(), -1000
  160.         }
  161.     } else if CursorLocked {
  162.         DllCall("ClipCursor", "Ptr", 0)
  163.         CursorWasLockedBeforeFocusLoss := true
  164.         CursorLocked := false
  165.         ToolTip "Cursor auto-unlocked (focus lost)"
  166.         SetTimer () => ToolTip(), -1000
  167.     }
  168. }
  169.  
  170. StartGameWatcher() {
  171.     Global GameWatcherRunning
  172.  
  173.     if !GameWatcherRunning {
  174.         SetTimer(CheckGameRunning, 2000)
  175.         GameWatcherRunning := true
  176.     }
  177. }
  178.  
  179. CheckGameRunning() {
  180.     Global GameTitle, GameExe, GameWatcherRunning
  181.  
  182.     hwnd := WinExist(GameTitle)
  183.     if hwnd && WinGetProcessName(hwnd) = GameExe {
  184.         SetTimer(CheckWindowFocus, 200)
  185.         SetTimer(CheckGameRunning, 0)
  186.         GameWatcherRunning := false
  187.         ToolTip "Game relaunched — cursor tracking re-enabled"
  188.         SetTimer () => ToolTip(), -1000
  189.     }
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement