How to hide/unhide current acctive windows?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

How to hide/unhide current acctive windows?

05 Feb 2022, 01:13

Hi there,

I have a script which hides/unhides just a specific window. I am trying to make something which will hide/unhide just current active windows gradually.

Please help.

This is my script for hide/unhide the specific window...

Code: Select all

;

DetectHiddenWindows, On
SetTitleMatchMode, 2 ;partial match 
!`::  ; Alt+` ; Hide/Unhide Firefox Private Browsing
IfWinExist, Mozilla Firefox (Private Browsing)
If Hidden 
{ 
  WinShow
;  WinActivate
} 
Else 
{ 
  WinHide
} 
Hidden := !Hidden ;Toggle hidden 
Return

;
[Mod edit: [code][/code] tags added.]
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: How to hide/unhide current acctive windows?

05 Feb 2022, 02:55

Check out this post: viewtopic.php?t=93964#p416478
It will minimize aka hide any number of windows to the system tray and show its icon there too.

HTH
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

Re: How to hide/unhide current acctive windows?

05 Feb 2022, 03:18

Hi! Thanks for the Reply.

I had found out this by myself:

Code: Select all

!3::  ; Alt+3 ; Hides Active Window
DetectHiddenWindows, On
WinGet, active_id, ID, A
IfWinActive, ahk_id %active_id%
WinHide
Return
[Mod edit: [code][/code] tags added.]

It hides the active windows, but now unable to bring those windows back? Something similar as below, but it doesn't seem to work somehow...

Code: Select all

!4::  ; Alt+4 ; UnHides Active Window
DetectHiddenWindows, On
WinGet, active_id, ID, A
If Hidden 
WinShow, active_id, ID, A
What to put now bring those hidden windows back???
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: How to hide/unhide current acctive windows?

05 Feb 2022, 03:59

Example:

Code: Select all

#NoEnv
OnExit, exit

!3::ShowHideWindows("A", 0)    ; Hide
!4::ShowHideWindows()          ; Show All

ShowHideWindows(wintitle := "A", show := 1)
{
    static windows := []
    
    if (show)
    {
        for each, active_id in windows
            WinShow, % "ahk_id " . active_id
        windows := []
    }
    else
    {
        WinGet, active_id, ID, % wintitle
        windows.push(active_id)
        WinHide, % "ahk_id " . active_id
    }
}

exit:
    ShowHideWindows()
    ExitApp
Try testing it on some empty notepad windows to see how it works.

Note: since we have the window IDs stored in an array DetectHiddenWindows, On is not needed.

HTH
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

Re: How to hide/unhide current acctive windows?

05 Feb 2022, 04:19

Thank you for the reply dear,

This is similar to this

Code: Select all

hiddenWindowNumber = 0
!3::
   hiddenWindowNumber++
   WinGet winID, ID, A
   WinHide A
   hiddenWindow%hiddenWindowNumber% := winID
Return

!4::
   ; Show all hidden windows
   ; You can also create a menu (for example) listing the windows
   ; allowing you to choose a specific window to unhide
   Loop %hiddenWindowNumber%
   {
      winID := hiddenWindow%A_Index%
      WinShow ahk_id %winID%
   }
Return
[Mod edit: [code][/code] tags added.]

Only the issue is these does not auto activate the next opened window after hiding and it unhides all together...

yet it was a great help dear...
Last edited by gregster on 05 Feb 2022, 04:20, edited 1 time in total.
Reason: Please use code tags. Thank you!
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: How to hide/unhide current acctive windows?

05 Feb 2022, 04:38

You would be better off with the link i posted 1st then you can double click the icon in the system tray to unhide the window you choose. You can visually see whats going on and would be hard to mess up.

I guess if you want to activate the next window in the z-order after hiding a window you will need to get the list of current windows and activate the 1st one.
VISHALVODRO
Posts: 26
Joined: 02 Apr 2016, 05:53

Re: How to hide/unhide current acctive windows?

05 Feb 2022, 04:53

Ok, bit of hard work seems like... Thank you dear...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 78 guests