Win+1 to 9 keys, only min/max first window, modifier keys for next window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Kagerjay
Posts: 9
Joined: 04 Nov 2017, 08:57
Contact:

Win+1 to 9 keys, only min/max first window, modifier keys for next window

18 Nov 2017, 13:02

I use win+1, win+2, win+3, win+4 ..... win+9 keys fairly frequently

Is there a way to have an autohotkey to do the following?

Say I have chrome in position 9 on my taskbar.

If chrome has 3 windows

1.WIN+9 only maximizes / minimizes 1st window in stack
2. SHIFT+WIN+9 maximizes / minimizes only the 2nd window
3. Ctrl+WIN+9 maximizes/minimizes only the 3rd window

Image
Last edited by Kagerjay on 20 Nov 2017, 08:36, edited 3 times in total.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Win+1 to 12 keys, only min/max first window, modifier keys for next window

18 Nov 2017, 13:49

Here's what I would do:

Code: Select all

+#9::Send #{9 2}
^#9::Send #{9 3}
I personally tested it by changing all the nines into 4s. I had 3 Notepad windows open. The default #4 didn't need to be an autohotkey hotkey - we don't have to change the native behavior.

This works because normal behavior on Windows (at least Windows 8.1) is if you hold LWin and then press 4 or 9 or whichever number matches your program multiple times, you can cycle through the list of windows.

Edit: Ooops, this doesn't fully answer your question. This will only activate the corresponding window. To Minimize/Maximize it, you'll need to some more steps, including overwriting or supplementing the default behavior of the #9 windows hotkey. I would use a Sleep 50 to use WinMaximize on the (now) active window myself. However, this leaves the problem of Minimizing it. I would capture the Active Window title with WinGetTitle before doing the artificial Send #{9 2} commands. Then, after the Send has processed, get the Active Window again. Compare the two values. If they are the same, you just activated the already-active window, which means you probably want to minimize it. So then you run the WinMinimize command instead of WinMaximize.

Also see the tutorial if you're just starting out. And recognize there is a difference between single-line vs multi-line hotkeys.

Gotta run so sorry for not giving a better answer. Hope this helps!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mamo691, mikeyww, MrDoge, ReyAHK and 244 guests