Page 1 of 1

Minimize / Restore multiple windows

Posted: 21 Apr 2016, 08:44
by Joefango
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

Re: Minimize / Restore multiple windows

Posted: 21 Apr 2016, 09:12
by jmeneses
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


Re: Minimize / Restore multiple windows

Posted: 21 Apr 2016, 10:10
by Joefango
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 ?

Re: Minimize / Restore multiple windows

Posted: 25 Apr 2016, 02:15
by jmeneses
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              

Re: Minimize / Restore multiple windows

Posted: 25 Apr 2016, 06:10
by jmeneses
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