Owen McGrath
Owen McGrath

Reputation: 21

AHK WinMaximize not working properly

Im writing a script in AutoHotkey that is supposed to place a window that gets opened to a certain monitor (this setup has 3 monitors in a an L shape flipped over the vertical axis). The window gets moved to the correct monitor, but for some reason, the window doesnt maximize. When I click the maximize icon in the upper right, it maximizes as it normally should, but for some reason the script wont maximize it. I have gotten other windows to maximize using the line "WinMaximize" but for some reason I can not get this certain window to maximize. My Code is below

WinWait, Alarms
    WinActivate                                         ;Activate Window
    WinGetPos, Xpos, Ypos                               ;Get Window Position
    XPosPlus:=(Xpos + 1920)                             ;Get Monitor 3 X coord
    YPosPlus:=(Ypos - 1080)                             ;Get Monitor 3 Y coord
    WinMove, %XPosPlus%, %YPosPlus%                     ;Move window to monitor 3
    WinMaximize                                        ;Maximize Window
    Send {tab}{tab}{tab}{tab}{tab}{tab}{tab}A{space}    ;Enter A into the proper textbox
    ExitApp                                             ;Close Script

Is this a bug in auto hotkey? Or perhaps there is a Windows setting pertaining to this window specifically?

Things I've tried

-Looping WinMaximize for 3 or 4 times

-Maximizing before I perform WinMove

-Maximizing the window and doing nothing else

None of this actually maximizes the window.

Upvotes: 1

Views: 1396

Answers (2)

Owen McGrath
Owen McGrath

Reputation: 21

Changing the border didnt work and made the window unusable. It turns out that the window would open in the same location every time so i wrote a line that would click on the maximize icon rather than having it do it behind the scenes. This made my script work

Upvotes: 1

PGilm
PGilm

Reputation: 2312

Some windows (border types) don't respond well to WinMax. Does it work on your primary monitor? I guess not . . .

Oh well, you will need to look into WinSet, Style, 0x40000 and probably followed by WinSet, Redraw and you should look at the help on these commands (see below) for important limitations and workarounds:

WinWait, Alarms
    WinActivate                                         ;Activate Window

    WinSet, Style, 0x40000                              ;Apply sizing border
    WinSet, Reraw                                       ;Redraw window with sizing border

    WinGetPos, Xpos, Ypos                               ;Get Window Position
    XPosPlus:=(Xpos + 1920)                             ;Get Monitor 3 X coord
    YPosPlus:=(Ypos - 1080)                             ;Get Monitor 3 Y coord
    WinMove, %XPosPlus%, %YPosPlus%                     ;Move window to monitor 3
    WinMaximize                                         ;Maximize Window
    Send {tab}{tab}{tab}{tab}{tab}{tab}{tab}A{space}    ;Enter A into the proper textbox
    ExitApp                                             ;Close Script

Check out https://autohotkey.com/docs/commands/WinSet.htm

Hth

Upvotes: 3

Related Questions