positions := {} WidthOrig := A_ScreenWidth HeightOrig := A_ScreenHeight RegRead, Width, HKEY_CURRENT_USER\Software\2KCUSTOM, Width RegRead, Height, HKEY_CURRENT_USER\Software\2KCUSTOM, Height If (ErrorLevel = 1) { Width := 1024 Height := 768 } Gui, Add, Edit, x16 y30 w60 h20 vWidth, %Width% Gui, Add, Edit, x96 y30 w60 h20 vHeight, %Height% Gui, Add, Button, x166 y30 w50 h20 , OK Gui, Add, Text, x16 y10 w180 h20 +BackgroundTrans, Choose a custom resolution: Gui, Add, Text, x83 y33 w10 h12 +BackgroundTrans, x ; Generated using SmartGUI Creator 4.0 Gui, Show, x321 y259 h61 w227, SimCity 2000 Network Edition Return GuiClose: ExitApp ButtonOk: Gui, Submit RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\2KCUSTOM, Width, %Width% RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\2KCUSTOM, Height, %Height% Run, 2KCLIENT.EXE,,Max,pid Loop { WinWaitActive, ahk_pid %pid% Save() ChangeResolution(Width, Height) SetTitleMatchMode, RegEx WinMaximize, ahk_class ^Afx:.* SetTitleMatchMode, 3 Wait: WinWaitNotActive, ahk_pid %pid% IfWinActive, ahk_pid %pid% Goto, Wait ChangeResolution(WidthOrig, HeightOrig) Restore() If !WinExist("ahk_pid " . pid) ExitApp } Return ChangeResolution(Screen_Width := 1920, Screen_Height := 1080, Color_Depth := 32) { VarSetCapacity(Device_Mode,156,0) NumPut(156,Device_Mode,36) DllCall( "EnumDisplaySettingsA", UInt,0, UInt,-1, UInt,&Device_Mode ) NumPut(0x5c0000,Device_Mode,40) NumPut(Color_Depth,Device_Mode,104) NumPut(Screen_Width,Device_Mode,108) NumPut(Screen_Height,Device_Mode,112) Return DllCall( "ChangeDisplaySettingsA", UInt,&Device_Mode, UInt,0 ) } Save() { global positions positions := {} WinGet, id, list,,, ahk_exe 2KCLIENT.EXE Loop, %id% { i := id%A_Index% WinReallyGetPos(i, x, y, w, h) WinGetTitle, title, ahk_id %i% positions[i] := [x, y, w, h] } } Restore() { global positions For i, props in positions { x := props[1] y := props[2] w := props[3] h := props[4] WinReallyMove(i, x, y, w, h) } } WinReallyGetPos(hwnd, ByRef x, ByRef y, ByRef w="", ByRef h="") { VarSetCapacity(wp, 44), NumPut(44, wp) DllCall("GetWindowPlacement", "uint", hwnd, "uint", &wp) x := NumGet(wp, 28, "int") y := NumGet(wp, 32, "int") w := NumGet(wp, 36, "int") - x h := NumGet(wp, 40, "int") - y } WinReallyMove(hwnd, x, y, w, h) { VarSetCapacity(wp, 44, 0), NumPut(44, wp, "uint") NumPut(5, wp, 8, "uint") ; SW_SHOW NumPut(x, wp, 28, "int") NumPut(y, wp, 32, "int") NumPut(w + x, wp, 36, "int") NumPut(h + y, wp, 40, "int") DllCall("SetWindowPlacement", "ptr", hwnd, "ptr", &wp) }