Minimize / Restore multiple windows

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Joefango
Posts: 30
Joined: 05 Mar 2016, 07:36

Minimize / Restore multiple windows

21 Apr 2016, 08:44

Hello,

I'm trying to achieve something simple, I have 3 windows of the same program (windows builtin photo viewer) french traduction = Visionneuse de photos Windows

What I want is toggle state with a shorcut between show/minimize or show/hide while working in an other application. I want them visible with a shortcut, and if they are visible I want them to hide or minimize.

I started with something like this but I don't know how to get the state of these specific windows ?

Code: Select all

SetTitleMatchMode, 2
WinGet MyList, List, Visionneuse
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: Minimize / Restore multiple windows

21 Apr 2016, 09:12

Hi Joefango two examples with notepad

Code: Select all

Loop 5
{
 Run notepad
  GroupAdd, MyNotepads, ahk_exe notepad.exe	 
}
Sleep 3000
;Example with group
WinMinimize ahk_group MyNotepads
Sleep 3000
WinMaximize ahk_group MyNotepads

;Exemple with gete list
WinGet MyList, List, ahk_exe notepad.exe   
Loop % MyList
 WinMinimize ahk_exe notepad.exe 

ExitApp

Donec Perficiam
Joefango
Posts: 30
Joined: 05 Mar 2016, 07:36

Re: Minimize / Restore multiple windows

21 Apr 2016, 10:10

Thanks, first time I use a loop!
I replaced WinMaximize by WinRestore because I don't want Windows to be maximized

Code: Select all

#IfWinExist ahk_class GHOST_WindowClass
Up::
Loop 5
{
  GroupAdd, WindowsToHide, ahk_class Photo_Lightweight_Viewer
}
WinMinimize ahk_group WindowsToHide
return

Down::
Loop 5
{
  GroupAdd, WindowsToHide, ahk_class Photo_Lightweight_Viewer
}
WinRestore ahk_group WindowsToHide
return
#IfWinExist
It works fine but how I could make a "switch" between those two states with only one shorcut ?
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: Minimize / Restore multiple windows

25 Apr 2016, 02:15

Try this

Code: Select all

/*
SC_RESTORE  0xF120
SC_MINIMIZE 0xF020 
*/
#IfWinExist ahk_class GHOST_WindowClass
Up::
Down::
Loop 5
  GroupAdd, WindowsToHide, ahk_class Photo_Lightweight_Viewer

PostMessage, 0x112, %  (A_ThisHotkey = "Down" ? "0xF120" : "0xF020"),,, ahk_group WindowsToHide
#IfWinExist              
Donec Perficiam
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: Minimize / Restore multiple windows

25 Apr 2016, 06:10

THe last post not work!!! :shock: :shock:
Needless groupadd ever, once at the beginning is enough

Code: Select all

#NoEnv
#SingleInstance force
#Persistent 
GroupAdd, WindowsToHide, ahk_class Photo_Lightweight_Viewer
Return

#IfWinExist ahk_class GHOST_WindowClass
Up::
Down::
%A_ThisHotkey%()
Return	
#IfWinExist

UP(){ 
WinMinimize ahk_group WindowsToHide
Return
}	
	
DOWN(){
WinRestore ahk_group WindowsToHide
Return
}	
#IfWinExist              
And if you know the executable that works well

Code: Select all

#NoEnv
#SingleInstance force
#Persistent 
processName := "YourEXEC.exe"   
Return

#IfWinExist ahk_class GHOST_WindowClass
Up::
Down::
for process in ComObjGet("winmgmts:").ExecQuery("Select ProcessId from Win32_Process WHERE Name LIKE '%" . processName . "%'")
 PostMessage, 0x112, (A_ThisHotkey = "Down" ? 0xF120 : 0xF020) ,,, % "ahk_pid " process.processId

#IfWinExist  
Donec Perficiam

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gabelynn1 and 330 guests