Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Fade Inactive Windows


  • Please log in to reply
118 replies to this topic
earlsd
  • Guests
  • Last active:
  • Joined: --
Here's some code to fade your inactive windows like XFCE. I've used in on Win7:


;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       WinNT
; Author:         David Earls
;
; Script Function:
;	Ghost inactive Windows like XFCE
;
; Attribution: The code to loop through windows was paraphrased from the AHK forums.
; script of Unambiguous adjusted for use with PSPad


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance, force
DetectHiddenWindows, Off 

iniread, TransLvl, fadetoblack.ini, Preferences, Transparent, 150
iniread, delay, fadetoblack.ini, Preferences, Delay, 0

menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15
menu, tray, nostandard
menu, tray, add, &Configure, Configure
menu, tray, default, &Configure
menu, tray, add
menu, tray, add, E&xit, ExitRoutine
menu, tray, tip, Fades Inactive Windows - Please exit properly.


OnExit, ExitRoutine
#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_trans, ID, ahk_id %this_id%
    WinGet, Trans, Transparent, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    
    ;Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd ;Look down
        continue
    if class = Button ;Start Menu
        continue
    

    ; if active task, Set vis.
    IfWinActive, ahk_id %id_trans%
	{
       winset, Transparent, Off, ahk_id %id_trans%
	   continue
   }
    If Trans = %TransLvl% ; already Transparent
        continue
    if delay
    {
        if wininactive%ID_trans% < %delay%
             wininactive%ID_trans% += 1
        else
        {
            Winset,Transparent, %TransLvl%, ahk_id %id_trans%
            wininactive%ID_min% = 0
        }
    }
    else    
       Winset,Transparent, %TransLvl%, ahk_id %id_trans%
}
return


ExitRoutine:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_trans, ID, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    ;Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd
        continue
   if class = Button ;you get a large square if you remove this.
       continue
    
   Winset,Transparent,off, ahk_id %id_trans%

}
ExitApp
return

Configure:
gui, add, text,,Transparency:
gui, add, text,,Ghost
gui, add, slider,x+5 vTransSlider Range20-255 tooltip,%TransLvl%
gui, add, text,x+5,HiDef
gui, add, text,xm,`nInactivity Delay (Seconds):
gui, add, text,,Zero
gui, add, slider,x+5 tooltip vDelaySlider Range0-90, %delay%
gui, add, text,x+5,Ninety
gui, add, button,xm,&Save
gui, show,,Configure
return ;the gui

buttonSave:
gui, submit
iniwrite, %TransSlider%, fadetoblack.ini, Preferences, Transparent
iniwrite, %DelaySlider%, fadetoblack.ini, Preferences, Delay
reload
return

GuiEscape:
GuiClose:
gui, destroy
return

return ;configure sub


bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
1. Can I use it with XP? 2. Does it work with AHK basic (classic)? 3. Does it work out-of-the-box? 4. Any mal-side-effects? Thanks!

earlsd
  • Guests
  • Last active:
  • Joined: --

1. Can I use it with XP? 2. Does it work with AHK basic (classic)? 3. Does it work out-of-the-box? 4. Any mal-side-effects? Thanks!


1. Probably (Not Tested)
2. Yes, I write everything for that because of L's code bloat.
3. I hope so.
4. If you kill it instead of exiting with the menu it will leave transparent windows, other than that I don't know of anything. I'm guessing it would slow the system down slightly if you are a performance freak.

P.S. let me know if there is anything wrong, I might be able to fix it. This isn't my first program. :wink:

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
I tested on my XP, and it promptly presented me with the following error message:

Error: Can't load icon. The current thread will exit.

-> menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15
___________________
Доверяй, но проверяй

Posted Image

earlsd
  • Guests
  • Last active:
  • Joined: --

I tested on my XP, and it promptly presented me with the following error message:

Error: Can't load icon. The current thread will exit.

-> menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15


You can safely comment out that line or point it at your preferred icon. That file comes with Windows 7 and it's a little light bulb icon.

To comment it out just put a ; in front of it.

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Thanks! I commented another line (2 lines altogether), so I guess this should work on XP?
; http://www.autohotkey.com/forum/viewtopic.php?p=435226#435226
; Fade Inactive Windows

; AutoHotkey Version: 1.x
; Language: English
; Platform: WinNT
; Author: David Earls
;
; Script Function:
; Ghost inactive Windows like XFCE
;
; Attribution: The code to loop through windows was paraphrased from 

the AHK forums.
; script of Unambiguous adjusted for use with PSPad

#NoEnv ; Recommended for performance and compatibility with future 

AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed 

and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance, force
DetectHiddenWindows, Off

; iniread, TransLvl, fadetoblack.ini, Preferences, Transparent, 150
iniread, delay, fadetoblack.ini, Preferences, Delay, 0

; menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15
menu, tray, nostandard
menu, tray, add, &Configure, Configure
menu, tray, default, &Configure
menu, tray, add
menu, tray, add, E&xit, ExitRoutine
menu, tray, tip, Fades Inactive Windows - please exit properly

OnExit, ExitRoutine
#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_trans, ID, ahk_id %this_id%
    WinGet, Trans, Transparent, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
   
    ; Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd ; Look down
        continue
    if class = Button ; Start Menu
        continue
   

    ; If active task, Set vis.
    IfWinActive, ahk_id %id_trans%
   {
       winset, Transparent, Off, ahk_id %id_trans%
      continue
   }
    If Trans = %TransLvl% ; Already Transparent
        continue
    if delay
    {
        if wininactive%ID_trans% < %delay%
             wininactive%ID_trans% += 1
        else
        {
            Winset,Transparent, %TransLvl%, ahk_id %id_trans%
            wininactive%ID_min% = 0
        }
    }
    else   
       Winset,Transparent, %TransLvl%, ahk_id %id_trans%
}
return

ExitRoutine:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_trans, ID, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    ; Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd
        continue
   if class = Button ; You get a large square if you remove this!
       continue
   
   Winset,Transparent,off, ahk_id %id_trans%

}
ExitApp
return

Configure:
gui, add, text,,Transparency:
gui, add, text,,Ghost
gui, add, slider,x+5 vTransSlider Range20-255 tooltip,%TransLvl%
gui, add, text,x+5,HiDef
gui, add, text,xm,`nInactivity Delay (Seconds):
gui, add, text,,Zero
gui, add, slider,x+5 tooltip vDelaySlider Range0-90, %delay%
gui, add, text,x+5,Ninety
gui, add, button,xm,&Save
gui, show,,Configure
return ; The GUI

buttonSave:
gui, submit
iniwrite, %TransSlider%, fadetoblack.ini, Preferences, Transparent
iniwrite, %DelaySlider%, fadetoblack.ini, Preferences, Delay
reload
return

GuiEscape:
GuiClose:
gui, destroy
return

return ; Configure sub
PS: In my case, nothing seems to fade?
___________________
Доверяй, но проверяй

Posted Image

earlsd
  • Guests
  • Last active:
  • Joined: --
; iniread, TransLvl, fadetoblack.ini, Preferences, Transparent, 150

The non-icon line you commented out is the one that sets the transparency level. If the INI file is not found it sets the variable to 150 so it should work with or without an ini. (Using the settings dialog creates the ini so you don't need to do it manually in any case.)

Was this line causing a problem for you? Or, I guess my question is why did you comment it out?

Also, for people wanting an actual fix for the icon issue it would be:

ifexist, %A_Windir%\System32\accessibilitycpl.dll
  menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15


bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Indeed, that line was giving me an error message similar to the first line. Is there any way around this problem?

; http://www.autohotkey.com/forum/viewtopic.php?p=435226#435226
; Fade Inactive Windows

; AutoHotkey Version: 1.x
; Language: English
; Platform: WinNT
; Author: David Earls
;
; Script Function:
; Ghost inactive Windows like XFCE
;
; Attribution: The code to loop through windows was paraphrased from the AHK forums.
; script of Unambiguous adjusted for use with PSPad

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance, force
DetectHiddenWindows, Off

; iniread, TransLvl, fadetoblack.ini, Preferences, Transparent, 150
iniread, delay, fadetoblack.ini, Preferences, Delay, 0

ifexist, %A_Windir%\System32\accessibilitycpl.dll
menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15
menu, tray, nostandard
menu, tray, add, &Configure, Configure
menu, tray, default, &Configure
menu, tray, add
menu, tray, add, E&xit, ExitRoutine
menu, tray, tip, Fades Inactive Windows - please exit properly

OnExit, ExitRoutine
#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_trans, ID, ahk_id %this_id%
    WinGet, Trans, Transparent, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
   
    ; Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd ; Look down
        continue
    if class = Button ; Start Menu
        continue
   

    ; If active task, Set vis.
    IfWinActive, ahk_id %id_trans%
   {
       winset, Transparent, Off, ahk_id %id_trans%
      continue
   }
    If Trans = %TransLvl% ; Already Transparent
        continue
    if delay
    {
        if wininactive%ID_trans% < %delay%
             wininactive%ID_trans% += 1
        else
        {
            Winset,Transparent, %TransLvl%, ahk_id %id_trans%
            wininactive%ID_min% = 0
        }
    }
    else   
       Winset,Transparent, %TransLvl%, ahk_id %id_trans%
}
return

ExitRoutine:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_trans, ID, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    ; Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd
        continue
   if class = Button ; You get a large square if you remove this!
       continue
   
   Winset,Transparent,off, ahk_id %id_trans%

}
ExitApp
return

Configure:
gui, add, text,,Transparency:
gui, add, text,,Ghost
gui, add, slider,x+5 vTransSlider Range20-255 tooltip,%TransLvl%
gui, add, text,x+5,HiDef
gui, add, text,xm,`nInactivity Delay (Seconds):
gui, add, text,,Zero
gui, add, slider,x+5 tooltip vDelaySlider Range0-90, %delay%
gui, add, text,x+5,Ninety
gui, add, button,xm,&Save
gui, show,,Configure
return ; The GUI

buttonSave:
gui, submit
iniwrite, %TransSlider%, fadetoblack.ini, Preferences, Transparent
iniwrite, %DelaySlider%, fadetoblack.ini, Preferences, Delay
reload
return

GuiEscape:
GuiClose:
gui, destroy
return

return ; Configure sub
___________________
Доверяй, но проверяй

Posted Image

earlsd
  • Guests
  • Last active:
  • Joined: --
There's really no way that particular line should be causing a problem unless something got corrupted when I posted to the forum. Try this link:

https://docs.google.... ... y=CNaz1dkE

Failing that try:
if errorlevel
  translvl=150

Below the iniread or just leave it commented out and insert your preferred transparency level somewhere in the format: translvl=150 If you do that the slider in the dialog will no longer effect the transparency level.

Sorry you're having so much trouble, but the iniread really should work.

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Thanks! The downloaded script seems to be working fine:

/*
 * * * Compile_AHK SETTINGS BEGIN * * *

[AHK2EXE]
Exe_File=%In_Dir%\fadetoblack.exe
Alt_Bin=C:\Program Files\AutoHotkey\Compiler\AutoHotkeySC_small.bin
Execution_Level=2
[VERSION]
Set_Version_Info=1
Company_Name=David Earls
File_Description=Fade inactive windows
File_Version=0.0.5.0
Inc_File_Version=0
Internal_Name=fadetoblack
Legal_Copyright=David Earls
Original_Filename=fadetoblack.ahk
Product_Name=Fade to Black
Product_Version=1.0.48.5
Set_AHK_Version=1
[ICONS]
Icon_1=%In_Dir%\fadetoblack.ahk_1.ico

* * * Compile_AHK SETTINGS END * * *
*/

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       WinNT
; Author:         David Earls
;
; Script Function:
;	Ghost inactive Windows like XFCE
;
; Attribution: The code to loop through windows was paraphrased from the AHK forums.
; script of Unambiguous adjusted for use with PSPad


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance, force
DetectHiddenWindows, Off 

iniread, TransLvl, fadetoblack.ini, Preferences, Transparent, 150
iniread, delay, fadetoblack.ini, Preferences, Delay, 0

ifexist %A_Windir%\System32\accessibilitycpl.dll
  menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15
menu, tray, nostandard
menu, tray, add, &Configure, Configure
menu, tray, default, &Configure
menu, tray, add
menu, tray, add, E&xit, ExitRoutine
menu, tray, tip, Fades Inactive Windows - Please exit properly.


OnExit, ExitRoutine
#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_trans, ID, ahk_id %this_id%
    WinGet, Trans, Transparent, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    
    ;Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd ;Look down
        continue
    if class = Button ;Start Menu
        continue
    

    ; if active task, Set vis.
    IfWinActive, ahk_id %id_trans%
	{
       winset, Transparent, Off, ahk_id %id_trans%
	   continue
   }
    If Trans = %TransLvl% ; already Transparent
        continue
    if delay
    {
        if wininactive%ID_trans% < %delay%
             wininactive%ID_trans% += 1
        else
        {
            Winset,Transparent, %TransLvl%, ahk_id %id_trans%
            wininactive%ID_min% = 0
        }
    }
    else    
       Winset,Transparent, %TransLvl%, ahk_id %id_trans%
}
return


ExitRoutine:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_trans, ID, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    ;Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd
        continue
   if class = Button ;you get a large square if you remove this.
       continue
    
   Winset,Transparent,off, ahk_id %id_trans%

}
ExitApp
return

Configure:
gui, add, text,,Transparency:
gui, add, text,,Ghost
gui, add, slider,x+5 vTransSlider Range20-255 tooltip,%TransLvl%
gui, add, text,x+5,HiDef
gui, add, text,xm,`nInactivity Delay (Seconds):
gui, add, text,,Zero
gui, add, slider,x+5 tooltip vDelaySlider Range0-90, %delay%
gui, add, text,x+5,Ninety
gui, add, button,xm,&Save
gui, show,,Configure
return ;the gui

buttonSave:
gui, submit
iniwrite, %TransSlider%, fadetoblack.ini, Preferences, Transparent
iniwrite, %DelaySlider%, fadetoblack.ini, Preferences, Delay
reload
return

GuiEscape:
GuiClose:
gui, destroy
return

return ;configure sub
___________________
Доверяй, но проверяй

Posted Image

earlsd
  • Guests
  • Last active:
  • Joined: --
Great! Now it's the weekend let's drink!

Thanks! The downloaded script seems to be working fine:

/*
 * * * Compile_AHK SETTINGS BEGIN * * *

[AHK2EXE]
Exe_File=%In_Dir%\fadetoblack.exe
Alt_Bin=C:\Program Files\AutoHotkey\Compiler\AutoHotkeySC_small.bin
Execution_Level=2
[VERSION]
Set_Version_Info=1
Company_Name=David Earls
File_Description=Fade inactive windows
File_Version=0.0.5.0
Inc_File_Version=0
Internal_Name=fadetoblack
Legal_Copyright=David Earls
Original_Filename=fadetoblack.ahk
Product_Name=Fade to Black
Product_Version=1.0.48.5
Set_AHK_Version=1
[ICONS]
Icon_1=%In_Dir%\fadetoblack.ahk_1.ico

* * * Compile_AHK SETTINGS END * * *
*/

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       WinNT
; Author:         David Earls
;
; Script Function:
;	Ghost inactive Windows like XFCE
;
; Attribution: The code to loop through windows was paraphrased from the AHK forums.
; script of Unambiguous adjusted for use with PSPad


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance, force
DetectHiddenWindows, Off 

iniread, TransLvl, fadetoblack.ini, Preferences, Transparent, 150
iniread, delay, fadetoblack.ini, Preferences, Delay, 0

ifexist %A_Windir%\System32\accessibilitycpl.dll
  menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15
menu, tray, nostandard
menu, tray, add, &Configure, Configure
menu, tray, default, &Configure
menu, tray, add
menu, tray, add, E&xit, ExitRoutine
menu, tray, tip, Fades Inactive Windows - Please exit properly.


OnExit, ExitRoutine
#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_trans, ID, ahk_id %this_id%
    WinGet, Trans, Transparent, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    
    ;Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd ;Look down
        continue
    if class = Button ;Start Menu
        continue
    

    ; if active task, Set vis.
    IfWinActive, ahk_id %id_trans%
	{
       winset, Transparent, Off, ahk_id %id_trans%
	   continue
   }
    If Trans = %TransLvl% ; already Transparent
        continue
    if delay
    {
        if wininactive%ID_trans% < %delay%
             wininactive%ID_trans% += 1
        else
        {
            Winset,Transparent, %TransLvl%, ahk_id %id_trans%
            wininactive%ID_min% = 0
        }
    }
    else    
       Winset,Transparent, %TransLvl%, ahk_id %id_trans%
}
return


ExitRoutine:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_trans, ID, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    ;Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd
        continue
   if class = Button ;you get a large square if you remove this.
       continue
    
   Winset,Transparent,off, ahk_id %id_trans%

}
ExitApp
return

Configure:
gui, add, text,,Transparency:
gui, add, text,,Ghost
gui, add, slider,x+5 vTransSlider Range20-255 tooltip,%TransLvl%
gui, add, text,x+5,HiDef
gui, add, text,xm,`nInactivity Delay (Seconds):
gui, add, text,,Zero
gui, add, slider,x+5 tooltip vDelaySlider Range0-90, %delay%
gui, add, text,x+5,Ninety
gui, add, button,xm,&Save
gui, show,,Configure
return ;the gui

buttonSave:
gui, submit
iniwrite, %TransSlider%, fadetoblack.ini, Preferences, Transparent
iniwrite, %DelaySlider%, fadetoblack.ini, Preferences, Delay
reload
return

GuiEscape:
GuiClose:
gui, destroy
return

return ;configure sub
___________________
Доверяй, но проверяй

Posted Image



Meetloaf
  • Members
  • 46 posts
  • Last active: Mar 05 2016 07:57 PM
  • Joined: 02 Jun 2008
Heh, your script hit LifeHacker this morning and has gone viral, kudos for that.

Is there a way we could step the transparency as to give it an actual "FADE" effect? Not sure if it would be "pretty" enough to do a manual step via a loop or something (AHK-padawan learner here), or if there are other ways. Just figured if we could figure something like that out, it would appear more polished.

Loving the script btw, though I did change:
SetTimer, CheckIfActive, 1000

to 200, since the delay was buggin' like mad =]

Thanks!

P.S. Anyway we could kill the tray icon...it removed my usual AHK tray icon from another script I typically run, and I'd like to get it back =][/code]

EDIT: I figured out how to remove the Tray icon, just had to comment out said lines =] Thanks again!

jesseelliott
  • Members
  • 26 posts
  • Last active: May 19 2011 07:40 PM
  • Joined: 11 Apr 2011
I noticed that if I changed the timer from 1000 to 200, AutoHotKey was taking 6% of my CPU.

I moved the Exclusions section and the processname line after the checks for title and class, and it dropped to 1%.

Awesome script by the way!

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       WinNT
; Author:         David Earls
;
; Script Function:
;   Ghost inactive Windows like XFCE
;
; Attribution: The code to loop through windows was paraphrased from the AHK forums.
; script of Unambiguous adjusted for use with PSPad


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance, force
DetectHiddenWindows, Off 

iniread, TransLvl, fadetoblack.ini, Preferences, Transparent, 150
iniread, delay, fadetoblack.ini, Preferences, Delay, 0

ifexist, %A_Windir%\System32\accessibilitycpl.dll
  menu, tray, icon, %A_Windir%\System32\accessibilitycpl.dll, 15
menu, tray, nostandard
menu, tray, add, &Configure, Configure
menu, tray, default, &Configure
menu, tray, add
menu, tray, add, E&xit, ExitRoutine
menu, tray, tip, Fades Inactive Windows - Please exit properly.


OnExit, ExitRoutine
#Persistent
SetTimer, CheckIfActive, 200
return



CheckIfActive:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    
    If title =
        continue

    WinGetClass class , ahk_id %this_id%

    if class = Shell_TrayWnd ;Look down
        continue
    if class = Button ;Start Menu
        continue
    
    winget processname,processname, ahk_id %this_id%

    ;Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue

    WinGet, id_trans, ID, ahk_id %this_id%
    WinGet, Trans, Transparent, ahk_id %this_id%

    ; if active task, Set vis.
    IfWinActive, ahk_id %id_trans%
   {
       winset, Transparent, Off, ahk_id %id_trans%
      continue
   }
    If Trans = %TransLvl% ; already Transparent
        continue
    if delay
    {
        if wininactive%ID_trans% < %delay%
             wininactive%ID_trans% += 1
        else
        {
            Winset,Transparent, %TransLvl%, ahk_id %id_trans%
            wininactive%ID_min% = 0
        }
    }
    else    
       Winset,Transparent, %TransLvl%, ahk_id %id_trans%
}
return


ExitRoutine:
WinGet, id, list, , , Program Manager
Loop, %id%
{
    StringTrimRight, this_id, id%a_index%, 0
    WinGetTitle, title, ahk_id %this_id%
    WinGet, id_trans, ID, ahk_id %this_id%
    winget processname,processname, ahk_id %this_id%
    WinGetClass class , ahk_id %this_id%
    ;Exclusions
    if ( processname = "PSPad.exe" and class = "TApplication" )
     continue
    If title =
        continue
    if class = Shell_TrayWnd
        continue
   if class = Button ;you get a large square if you remove this.
       continue
    
   Winset,Transparent,off, ahk_id %id_trans%

}
ExitApp
return

Configure:
gui, add, text,,Transparency:
gui, add, text,,Ghost
gui, add, slider,x+5 vTransSlider Range20-255 tooltip,%TransLvl%
gui, add, text,x+5,HiDef
gui, add, text,xm,`nInactivity Delay (Seconds):
gui, add, text,,Zero
gui, add, slider,x+5 tooltip vDelaySlider Range0-90, %delay%
gui, add, text,x+5,Ninety
gui, add, button,xm,&Save
gui, show,,Configure
return ;the gui

buttonSave:
gui, submit
iniwrite, %TransSlider%, fadetoblack.ini, Preferences, Transparent
iniwrite, %DelaySlider%, fadetoblack.ini, Preferences, Delay
reload
return

GuiEscape:
GuiClose:
gui, destroy
return

return ;configure sub


Meetloaf
  • Members
  • 46 posts
  • Last active: Mar 05 2016 07:57 PM
  • Joined: 02 Jun 2008
Awesome, thanks for the tip, trying that out now.

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