Sign in to follow this  
Followers 0
Rad

Move/Resizing non-autoit window makes it not redraw

3 posts in this topic

So I made a program that lets me resize a game when its in windowed mode, but after I resize it the window just stops redrawing.

I can fix this by using a program Ultramon to move it to my other monitor then move it back, I don't know how Ultramon does it, but that makes it start redrawing again.

I don't know if autoit has any functions to fix this but I've tried just moving the window to the other monitor, even after waiting, and also tried using _WinAPI_RedrawWindow().

I also tried both _WinAPI_MoveWindow() and Winmove()

Here is the important part of my code, making it have $WS_POPUP is one of the main reasons I am making this program. It is not any sort of cheat, I just prefer to run my games in "fake fullscreen" mode, which most games just half-ass windowed mode, except Blizzard games and Left 4 Dead.

func NoBorder()
    $win = WinGetHandle($title)
    _WinAPI_SetWindowLong($win, $GWL_STYLE, $WS_POPUP)
    sleep(500)
    _WinAPI_MoveWindow($win, $x, $y, $width, $height, false)
    ;Winmove($title, '', $x, $y, 1000, 700)
EndFunc

Share this post


Link to post
Share on other sites



i actually made a script to do just that, initally for warcraft III; i adapted it to work for any program (through the command line) however:

Opt("GUIOnEventMode", 1)
Global $vDLL = DllOpen("user32.dll"), $sized = False, $hWnd = 0, $oSize[4] = [0,0,500,500]
Global $winTitle = "[CLASS:Notepad; TITLE:Untitled]", $program = "Notepad"

If $CmdLine[0] Then
    $program = $CmdLine[1]
    $winTitle = $CmdLine[2]
EndIf

Func Running()
    If Not WinExists($winTitle, "") Then
        MsgBox(16, "Error", $program&" is not running." , 5)
        $hWnd = $sized = 0
        Return 1
    EndIf
    Return 0
EndFunc

Running()

Func Modify()
    Write("Modify")
    If Running() Then Return 1
    
    $hWnd = WinGetHandle($winTitle, "")
    If @error Then
        MsgBox(16, "Error", "Could not get the"&@CRLF&"handle of the window." , 5)
        Return 2
    EndIf

    WinActivate($winTitle, "")

    DllCall($vDll, "int", "SetWindowLong", "hwnd", $hWnd, "int", 0xFFFFFFF0, "int", 0x16CF0000)
    DllCall($vDll, "int", "SetWindowLong", "hwnd", $hWnd, "int", 0xFFFFFFEC, "int", 0x00040100)

    $oSize = WinGetPos($winTitle, "")
    If @error Then
        MsgBox(16, "Error", "Could not get the position"&@CRLF&" of the window." , 5)
        Return 3
    EndIf
    
    DllCall($vDll, "int", "SetWindowLong", "hwnd", $hWnd, "int", 0xFFFFFFF0, "int", BitAND(0x90000200, BitNOT(0x00FF0080)))
    DllCall($vDll, "int", "SetWindowLong", "hwnd", $hWnd, "int", 0xFFFFFFEC, "int", 0x00040040)
;~  EXSTYLE  0xFFFFFFEC
;~  STYLE    0xFFFFFFF0
    WinSetOnTop($winTitle, "", 1)
    WinMove($winTitle, "", 0, 0, @DesktopWidth, @DesktopHeight, 5)
    Return 0
EndFunc

Func Resize()
    Write("Resize")
    If Running() Then Return 1
    WinSetOnTop($winTitle, "", 0)
    If Not $hWnd Then $hWnd = WinGetHandle($winTitle, "")
    If @error Then
        MsgBox(16, "Error", "Could not get the"&@CRLF&"handle of the window." , 5)
        Return 2
    EndIf
    DllCall($vDll, "int", "SetWindowLong", "hwnd", $hWnd, "int", 0xFFFFFFF0, "int", 0x16CF0000)
    DllCall($vDll, "int", "SetWindowLong", "hwnd", $hWnd, "int", 0xFFFFFFEC, "int", 0x00040100)

    WinMove($winTitle, "", $oSize[0], $oSize[1], $oSize[2], $oSize[3], 2)
    $hWnd = 0
    Return 0
EndFunc

Func Write($data)
    ConsoleWrite($data)
    ConsoleWrite(@LF)
EndFunc

Func isDown($sHexKey)
    Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then 
        $a_R = 0
        Return 1
    EndIf
    $a_R = 0
    Return 0
EndFunc

Dim $main = GUICreate("", @DesktopWidth, 60, 0, 0, 0, 0x8)
GUICtrlCreateLabel(@CRLF&"Press both control (ctrl) buttons to toggle fullscreen."&@CRLF&"Click the icon in the taskbar to be able to Exit.", 0, 0, @DesktopWidth, 40, 1, 0x8)
GUISetState()
DllCall($vDll, "int", "SetWindowLong", "hwnd", $main, "int", 0xFFFFFFF0, "int", BitAND(0x90000200, BitNOT(0x00FF0080)))
DllCall($vDll, "int", "SetWindowLong", "hwnd", $main, "int", 0xFFFFFFEC, "int", 0x00040040)
Sleep(7000)
GUISetState(@SW_HIDE, $main)
GUIDelete($main)
$main = 0
Dim $time = 1
While True
    If (isDown('A2') And isDown('A3')) And TimerDiff($time) > 4000 Then
        If Not $sized Then
            $sized = Not Modify()
        ElseIf $sized Then
            $sized = Resize()
        EndIf
        $time = TimerInit()
    EndIf
    Sleep(5)
WEnd
Exit 0

Func OnAutoItExit()
    Resize()
    DllClose($vDll)
    $vDll = 0
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0