How to assign a hotkey to any random windows without change code all the time Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
willzheng7
Posts: 6
Joined: 09 Feb 2017, 14:38

How to assign a hotkey to any random windows without change code all the time

15 Feb 2017, 21:15

Let's say I want to assign 3 hotkey to 3 random opened window. such as "ALT+1" , "ALT+2" ,"ALT+3" , Press them to Activate specific window and Minimize it again and again.

For Windows 1 (active status):
------------------------------------------------------------------------------------------------
Press ALT +1 for the first time
Winget ahk_id ;Obtain current windows' ahk_id

Press ALT+1 again
if windows_Not_Active, Activate this windows with previous memorized "ahk_id"
Press ALT+1 again
if windows_Active, Minimize this windows with previous memorized "ahk_id"
And repeat this function.
------------------------------------------------------------------------------------------------

For Windows 2 (active status):
------------------------------------------------------------------------------------------------
Press ALT +2 for the first time
Winget ahk_id ;Obtain current windows' ahk_id

Press ALT+2 again
if windows_Not_Active, Activate this windows with previous memorized "ahk_id"
Press ALT+2 again
if windows_Active, Minimize this windows with previous memorized "ahk_id"
And repeat this function.
------------------------------------------------------------------------------------------------

For Windows 3 (active status):
;and so on and on.......

Basically, I want to press ALT+1 to Activate and Minimize windows 1 over and over again.
press ALT+2 to Activate and Minimize windows 2 over and over again.
press ALT+3 to Activate and Minimize windows 3 over and over again.


(English is not my tongue, this is my first time to ask question here, hope my English is easy to understand. Thanks for your help in advance.)
ManualColdLock
Posts: 175
Joined: 15 Dec 2016, 04:27

Re: How to assign a hotkey to any random windows without change code all the time  Topic is solved

15 Feb 2017, 22:11

Press Shift+Alt+1 to lock a window to number 1
Press Alt+1 to toggle it
same for 2 and 3

Code: Select all

+!1:: Window1 := WinExist("A")

!1::
IfWinActive, ahk_id %Window1%
	WinMinimize, ahk_id %Window1%
else
	WinActivate, ahk_id %Window1%
Return

+!2:: Window2 := WinExist("A")

!2::
IfWinActive, ahk_id %Window2%
	WinMinimize, ahk_id %Window2%
else
	WinActivate, ahk_id %Window2%
Return

+!3:: Window3 := WinExist("A")

!3::
IfWinActive, ahk_id %Window3%
	WinMinimize, ahk_id %Window3%
else
	WinActivate, ahk_id %Window3%
Return
willzheng7
Posts: 6
Joined: 09 Feb 2017, 14:38

Re: How to assign a hotkey to any random windows without change code all the time

16 Feb 2017, 11:17

It works,

Thank you ManualColdLock.

you made my day.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: coder96, Joey5 and 343 guests