Minimizing/Maximizing last found window

Get help with using AutoHotkey and its commands and hotkeys
nnllnnll
Posts: 2
Joined: 16 Sep 2020, 06:03
GitHub: jerrylususu

Minimizing/Maximizing last found window

Post by nnllnnll » 16 Sep 2020, 06:19

Hello everyone! I'm working on a little GUI application for my Windows tablet, which controls the window behind it (kind like a on-screen keyboard). I found that although I can send keystrokes without any issue, I could not minimize or maximize the underlying window. Using WinMinimize or WinMaximizewill cause my application to minimize or maximize, instead of the underlying window, which is not my desired behavior. I tried to add WinActivate, but it wasn't helping. I googled around yet found no useful solution, so I'm here to ask for help.

Attached is my code. Page Up/Page Down/Close is working as expected, but Max/Min is not.

Code: Select all

</s>Gui, +LastFound +AlwaysOnTop +ToolWindow +Caption +Border +E0x08000000 ; 0x08000000 WS_EX_NOACTIVATE
Gui, Add, Button, w90 h90 gMin, Min
Gui, Add, Button, w90 h90 gPgUP ,Page`nUp
Gui, Add, Button, w90 h90 gMax ys, Max
Gui, Add, Button, w90 h90 gPgDown , Page`nDown
Gui, Add, Button, w90 h90 gClose ys, Close
Gui, Show ,, SimpleControl
return

PgUP:
{
    SendInput, {PgUp}
    return
}

PgDown:
{
    SendInput, {PgDn}
    return
}

Min:
{
    ; WinActivate
    ; WinMinimize
    return
}

Max:
{
    ; WinActivate
    ; WinMaximize
    return
}

Close:
{
    SendInput, !{F4}
    return
}

GuiClose:
ExitApp<e>

nnllnnll
Posts: 2
Joined: 16 Sep 2020, 06:03
GitHub: jerrylususu

Re: Minimizing/Maximizing last found window

Post by nnllnnll » 16 Sep 2020, 06:27

I tried the following code, now it is working, but if I first click "Min" to minimize a window, then click "Max", nothing will happen. Is there any possible fix?

Code: Select all

Min:
{
    WinMinimize, A
    return
}

Max:
{
    WinMaximize, A
    return
}

User avatar
Xtra
Posts: 1919
Joined: 02 Oct 2015, 12:15

Re: Minimizing/Maximizing last found window

Post by Xtra » 16 Sep 2020, 10:13


Post Reply

Return to “Ask For Help”