Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Minimize Inactive Windows


  • Please log in to reply
6 replies to this topic
Unambiguous
  • Members
  • 16 posts
  • Last active: Mar 10 2011 06:42 PM
  • Joined: 18 May 2005
Well, I realize after the post yesterday that noone was really interested in the idea, so I gave it a try myself.

This script will minimize any inactive windows after n seconds. The reason for this is that I have a lot of windows open normally, and just forget they are there. This allows for a much cleaner workspace.

Its working OK for me now and with the time settings currently in place, it takes about 1 minute for an app to become minimized when in the background.

Change the filter section to match your apps.

#Persistent

DetectHiddenWindows, Off
SetTimer, CheckIfActive, 1000
return

CheckIfActive:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_min, ID, ahk_id %this_id%
    WinGet, minim , MinMax, ahk_id %this_id%
    ;blank
    If title = 
        continue
    ;filter
    If (title = "Desktop Coral" or title = "Serence Klipfolio")
        continue
    ; if minimized, restart on new app
    If minim = -1
        continue
    ; if active task, reset counter to 0
    IfWinActive, ahk_id %id_min%
        {
            wininactive%ID_min% = 0
            continue
        }
    ; if counter is less than 60, add 1 or minimize and reset
    If wininactive%ID_min% < 60
    {
        If wininactive%ID_min% =
            wininactive%ID_min% = 0
        wininactive%ID_min% += 1
    }
    Else
    {
        WinMinimize, ahk_id %id_min%
        wininactive%ID_min% = 0
    }
        
}
return


robiandi
  • Guests
  • Last active:
  • Joined: --
Thanks for the nice idea.

If you are using the editor PSPad you have to add the following lines
winget      processname,processname, ahk_id %this_id%
WinGetClass class                  , ahk_id %this_id%

if ( processname = "PSPad.exe" and class = "TApplication" )
  continue
because there is still another relevant class: TfPSPad
Without these lines the Editor will be minimized although you are just typing in it.

robiandi
  • Guests
  • Last active:
  • Joined: --
For the sake of simplicity I will write down the whole script
; script of Unambiguous adjusted for use with PSPad
#Persistent
SetTimer, CheckIfActive, 1000
return

CheckIfActive:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_min, ID, ahk_id %this_id%
    WinGet, minim , MinMax, ahk_id %this_id%

    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue

    If title =
        continue
    If minim = -1 ; alread minimized
        continue
    ; if active task, reset counter to 0
    IfWinActive, ahk_id %id_min%
            continue
    ; if counter is less than 60, add 1 or minimize and reset
    If wininactive%ID_min% < 60
      wininactive%ID_min% += 1
    Else
    {
        WinMinimize, ahk_id %id_min%
        wininactive%ID_min% = 0
    }
}
return       


kalltheway
  • Guests
  • Last active:
  • Joined: --
Is there a way to change this script so that instead of minimizing all inactive windows after n seconds, they minimize with the touch of a button on the keyboard?

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Unambiguous,

Thanks for the script. This is absolutely fantastic! Can you offer a version of the script to do the same thing through a key board key combination or an F key, etc.? :lol:

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
I have renamed it InWin Minimizer and added to my active (in-use) AHK apps. :lol: The only issue I see is the frequent minimizing action going on in the background that could be distracting... If only it could be done transparently. :idea:

litojuliano
  • Members
  • 1 posts
  • Last active: Jan 09 2014 08:40 AM
  • Joined: 08 Jan 2014

Well, I realize after the post yesterday that noone was really interested in the idea, so I gave it a try myself.

This script will minimize any inactive windows after n seconds. The reason for this is that I have a lot of windows open normally, and just forget they are there. This allows for a much cleaner workspace.

Its working OK for me now and with the time settings currently in place, it takes about 1 minute for an app to become minimized when in the background.

Change the filter section to match your apps.
 

#Persistent

DetectHiddenWindows, Off
SetTimer, CheckIfActive, 1000
return

CheckIfActive:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_min, ID, ahk_id %this_id%
    WinGet, minim , MinMax, ahk_id %this_id%
    ;blank
    If title = 
        continue
    ;filter
    If (title = "Desktop Coral" or title = "Serence Klipfolio")
        continue
    ; if minimized, restart on new app
    If minim = -1
        continue
    ; if active task, reset counter to 0
    IfWinActive, ahk_id %id_min%
        {
            wininactive%ID_min% = 0
            continue
        }
    ; if counter is less than 60, add 1 or minimize and reset
    If wininactive%ID_min% < 60
    {
        If wininactive%ID_min% =
            wininactive%ID_min% = 0
        wininactive%ID_min% += 1
    }
    Else
    {
        WinMinimize, ahk_id %id_min%
        wininactive%ID_min% = 0
    }
        
}
return

Hi,

 

This is exactly what I try to aim, may I know what programming language is this?

 

thanks