3

I simply wish to be able to toggle with a hotkey Minimize & Maximize on one certain full screen app that I always use. I want to use this for only one app, and not whichever app has focus.

I have read dozens of ways to do this online, none of which have worked.

I know there are a few commands that I could use:

WinMinimize, A
WinMaximize, A

But I am not sure how to string it all together. When looking for examples I came up with this somewhere:

^#n::
IfWinExist, ahk_class Notepad
{
WinGet,WinState,MinMax,ahk_class Notepad
If WinState = -1
   WinMaximize
else
   WinMinimize
}
; else
;   Run, Notepad
Return

However this only maximized my app, and not minimized it. Perhaps this was due to the fact app was a fullscreen app, i don't know.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Kalamalka Kid
  • 240
  • 4
  • 14
  • You should describe what you've tried and how it didn't work for you. See [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). Without your details, the best I can suggest is to use [ActivateWindow](https://autohotkey.com/docs/commands/WinActivate.htm), [WinMaximize](https://autohotkey.com/docs/commands/WinMaximize.htm) and [WinMinimize](https://autohotkey.com/docs/commands/WinMinimize.htm) – Jim U Mar 21 '17 at 13:40
  • @JimU hi thanks. I have posted an example of the code that didtn work. – Kalamalka Kid Mar 21 '17 at 19:59
  • The code for ^#n you posted works for me. I tested it in isolation by 1) right clicking the AutoHotKey icon on the task bar and choosing `Edit This Script`, 2) pasting your code into it, replacing the existing code, 3) right clicking the AutoHotKey icon again and choosing `Reload This Script`, 4) Starting notepad, 5) pressing Control+Win+N repeatedly - The notepad window maximized and minimized as intended. I had only one instance of Notepad running. – Jim U Mar 21 '17 at 20:46
  • @JimU THanks for the tip. I understand how to reload and edit scripts.. So this being said, this might work fine for Notepad, but it does not work my full screen game. I mentioned this in the original post about the app being full screen. – Kalamalka Kid Mar 22 '17 at 00:02

4 Answers4

2

You can minimize and maximize by checking the value of the MinMax value while using WinGet.

; To toggle Citrix remote desktop window by using Function 12 key

F12::
; get MinMax state for the given title and save it to variable MX
WinGet MX, MinMax, YourWindowTitle

; if it is maximized, minimize it
if (MX==1)
    WinMinimize YourWindowTitle
; if it is minimized, maximize it
else if (MX==-1)
    WinMaximize YourWindowTitle

return

This script toggles minimize and maximize the given window with F12 key.

RamValli
  • 4,389
  • 2
  • 33
  • 45
1

I was able to retrieve some information from another website which helped me come to an answer which might be useful for other users. When used with AutoHotKey this script will work for full-screen apps by using the following code:

Joy12::
WinGetPos, X, Y, Width, Height, WindowName
if (X == -32000)
WinMaximize, WindowName
else if (X == 0 and Y == 0 and Width == 1920 and Height == 1080)
WinMinimize, Resident Evil 4
WinActivate, Program Manager
return

users may have to make small changes to the code, replacing Joy12 with whatever key they wish to use, and replacing WindowName with the name of window they wish to use. Users may also have to change the following values:

1920 and Height == 1080

to whatever their full screen resolution is.

Kalamalka Kid
  • 240
  • 4
  • 14
0

I had the same requirement for Calculator, after a bit! of experimenting I came up with this:

;! is alt
!c:: ;calculator

IfWinExist Calculator
{  
  Gosub, process_calc
} else {
   run calc
}
return

process_Calc:
  WinGetPos, x, y,,,Calculator
  if (x = 0) {                ; Calculator is minimized to Taskbar
  WinMinimize Calculator      ;WinMinimize is needed to select Calculator(other Win.... didn't work).
  WinRestore Calculator
} else {
  WinMinimize Calculator      ; Alt-C now alternates between Minimize/Restore to/from Taskbar
}
return
0

For some reason the older code I posted above is no longer working, but with the help of @Ram I was able to make something that works well with this game:

#SingleInstance Force
SetWorkingDir %A_ScriptDir%
if not A_IsAdmin
    Run *RunAs "%A_ScriptFullPath%"

1Joy10::
; get MinMax state for the given title and save it to variable MX
WinGet MX, MinMax, Resident Evil 4

if (MX==-1)
    WinMaximize Resident Evil 4
    WinActivate
Return
    
#IfWinActive Resident Evil 4
1Joy10::
Send, {ALT DOWN}{TAB}{ALT UP}
Return
Kalamalka Kid
  • 240
  • 4
  • 14