This program rockkkk!!!! You my friend are awesome! I have stumbled upon this holy grail today! T'is a good day. On behalf of the internet, THANK YOU!
I do have a request (not that your program isn't awesome enough already) for a future update if you are not busy. I've been using another AHK program call Sweptaway
http://lifehacker.co...ws?tag=software and it does automatic minimize (to task bar only, which is the drawback) after a preset time (in seconds, but I prefer milliseconds) when the windows is not active. I believes he also posted his source code, but I'll put it here also just in case. I'm a little slow with my third mouse button sometime and was wondering if you can incorporate his auto minimize after a certain amount of time into your program. His program also uses an "Exclude" to exclude programs that he doesn't want to automatically minizes, but I find it too much troublesome since exclude a lot of programs. If you can make it "Include" instead, that would be much better.
Again, thank you very much for your creation!
; Swept Away
; Author: Adam Pash <[email protected]>
; A simple implementation of Spirited Away (http://www.versiontracker.com/dyn/moreinfo/macosx/24877) for Windows
; for Windows:
; Script Function:
; Designed to minimize unused windows after a pre-defined time
; useful for uncluttering your active desktop
;
#SingleInstance,Force
#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%"
DetectHiddenWindows,Off
Gosub,GetProcesses
Gosub,READINI
Gosub,TRAYMENU
Gosub,RESOURCES
collection=
disable := 0
currentTime = %A_Now%
SetTimer, Start, %PollTime%
GetProcesses:
WinGet,windows,List
Loop, %windows%
{
StringTrimLeft,windowID,windows%A_Index%,0
WinGet,process,ProcessName,ahk_id %windowID%
processes = %processes%,%process%
}
return
START:
WinGet,windows,List
Loop, %windows%
{
StringTrimLeft,windowID,windows%A_Index%,0
; WinGet,processID,PID,ahk_id %windowID%
; next := A_Index + 1
; StringTrimLeft,windowID2,windows%next%,0
; WinGet,processID2,PID,ahk_id %windowID2%
; if (processID = processID2)
; continue
if collection not contains %windowID%
{
WinGet,winState,MinMax,ahk_id %windowID%
if winState != -1
{
WinGetTitle,title,ahk_id %windowID%
if title not contains Program Manager
{
if title <>
{
WinGet,controls,ControlList,ahk_id %windowID%
if controls not contains SysPager
{
WinGet,processName,ProcessName,ahk_id %windowID%
if processName not contains .scr
{
if exclude not contains %processName%
{
collection = %collection%,%windowID%
%windowID%_Now = %A_Now%
StringTrimLeft,windowID_Now,%windowID%_Now,0
Menu,ExcludeSub,Add,%processName%,EXCLUDE
Menu,TRAY,Add,&Exclude,:ExcludeSub
;MsgBox, exclude didn't contain process
currentTime = %A_Now%
}
else
{
Menu,ExcludeSub,Add,%processName%,EXCLUDE
Menu,ExcludeSub,Check,%processName%
Menu,TRAY,Add,&Exclude,:ExcludeSub
IfExist collection\%windowID%
{
StringReplace,collection,collection,%windowID%,
}
}
}
;}
}
}
}
}
else
{
StringReplace,collection,collection,%windowID%,
}
}
IfWinActive, ahk_id %windowID%
{
%windowID%_Now = %A_Now%
StringTrimLeft,windowID_Now,%windowID%_Now,0
}
}
Loop,Parse,collection,CSV
{
if A_Index != 1
{
StringTrimLeft,windowTime,%A_LoopField%_Now,0
diff = %windowTime%
EnvSub,diff,A_Now,seconds
Transform,diff,Abs,diff
if diff > %sweepTime%
{
WinGet,mini,MinMax,ahk_id %A_LoopField%
if mini != -1
{
IfWinNotActive,ahk_id %A_LoopField%
{
;WinMinimize,ahk_id %A_LoopField%
PostMessage, 0x112, 0xF020,,, ahk_id %A_LoopField% ; 0x112 = WM_SYSCOMMAND, 0xF020 = SC_MINIMIZE
;WinHide,ahk_id %A_LoopField%
StringReplace,collection,collection,`,%A_LoopField%,,All
}
}
else
StringReplace,collection,collection,`,%A_LoopField%,,All
}
}
}
return
TRAYMENU:
Menu,TRAY,NoStandard
Menu,TRAY,DeleteAll
Menu,TRAY,Add,&Preferences,PREFS
Loop,Parse,processes,CSV
{
if A_LoopField <>
{
Menu,ExcludeSub,Add,%A_LoopField%,EXCLUDE
if exclude contains %A_LoopField%
Menu,ExcludeSub,Check,%A_LoopField%
}
}
Menu,TRAY,Add,&Exclude,:ExcludeSub
Menu,TRAY,Add,&Help,HELP
Menu,TRAY,Add
Menu,TRAY,Add,&About...,ABOUT
Menu,TRAY,Add,&Disable,DISABLE
if disable = 1
Menu,Tray,Check,&Disable
Menu,TRAY,Add,E&xit,EXIT
Menu,TRAY,Default,&Preferences
Menu,Tray,Tip,Swept Away
Return
PREFS:
Gui,Destroy
Gui, Add, Text, x226 y40 w-10 h-10 , Text
Gui, Add, UpDown, x33266 y33010 w-33270 h-34060 , UpDown
Gui, Font, S12 CDefault, Arial
Gui, Add, Text, x16 y10 w170 h20 , Time before minimizing:
Gui, Add, Edit, vSeconds x26 y30 w100 h30 , %sweepTime%
IniRead,PollTime,sweptaway.ini,Preferences,PollTime
Gui, Add, Text, x16 y70 w330 h20 , Polling time in milliseconds:
Gui, Font, S10 CDefault, Arial
;Gui, Add, Text, x26 y90 h40 w330, This setting determines how often Swept Away checks out which windows are active. If you're having CPU problems, try adjusting the poll time to a higher number.
Gui, Add, Text, x186 y10 w80 h20 , (in seconds)
Gui, Add, Text, x210 y70 w120 h20 ,(requires restart)
Gui, Add, Text, x130 y100 w120 h20 , (1000 = 1 second)
Gui, Font, S12 CDefault, Arial
Gui, Add, Edit, vPoll x26 y90 w100 h30 , %PollTime%
Gui, Font, S10 CDefault, Arial
Gui, Font, S12 CDefault, Arial
Gui, Add, CheckBox,vCheck x46 y130 w240 h20 Checked%update%, Check for updates on start up
IniRead,OnStartup,sweptaway.ini,Preferences,Startup
Gui, Add,Checkbox, vStartup x46 yp+30 Checked%OnStartup%,Run Swept Away on start up
Gui, Font, S10 CDefault, Arial
Gui, Add, Button, x156 y180 w100 h30 gOK default,&OK
Gui, Add, Button, x266 y180 w90 h30 gCANCEL, Cancel
; Generated using SmartGUI Creator 4.0
Gui, Show, h215 w363,Swept Away Preferences
Return
OK:
Gui,Submit
Gui,Destroy
IniWrite,%Seconds%,sweptaway.ini,Preferences,Timer
IniWrite,%Check%,sweptaway.ini,Preferences,UpdateCheck
IniWrite,%Poll%,sweptaway.ini,Preferences,PollTime
If Startup = 1
{
IfNotExist %A_StartMenu%\Programs\Startup\Swept Away.lnk
;Get icon for shortcut link:
;1st from compiled EXE
if %A_IsCompiled%
{
IconLocation=%A_ScriptFullPath%
}
;2nd from icon in resources folder
else IfExist %A_WorkingDir%\resources\sweptaway.ico
{
IconLocation=%A_WorkingDir%\resources\sweptaway.ico
}
;3rd from the AutoHotkey application itself
else
{
IconLocation=%A_AhkPath%
}
;use %A_ScriptFullPath% instead of %A_WorkingDir%\texter.exe
;to allow compatibility with source version
FileCreateShortcut,%A_ScriptFullPath%,%A_StartMenu%\Programs\Startup\Swept Away.lnk,%A_WorkingDir%,,,%IconLocation%
}
else
{
IfExist %A_StartMenu%\Programs\Startup\Swept Away.lnk
{
FileDelete %A_StartMenu%\Programs\Startup\Swept Away.lnk
}
}
IniWrite,%Startup%,sweptaway.ini,Preferences,Startup
Gosub,READINI
return
CANCEL:
Gui,Destroy
return
EXCLUDE:
Menu,ExcludeSub,ToggleCheck,%A_ThisMenuItem%
if exclude not contains %A_ThisMenuItem%
IniWrite,%exclude%`,%A_ThisMenuItem%,sweptaway.ini,Preferences,Exclusions
else
{
StringReplace,exclude,exclude,`,%A_ThisMenuItem%,
IniWrite,%exclude%,sweptaway.ini,Preferences,Exclusions
}
IniRead,exclude,sweptaway.ini,Preferences,Exclusions
return
HELP:
Run,http://lifehacker.com/software//lifehacker-code-swept-away-windows-255055.php
return
ABOUT:
Gui,2: Destroy
Gui,2: Add, Picture, x16 y20 w60 h60 , sweptaway_logo.png
Gui,2: Font, S28 CDefault Bold, Verdana
Gui,2: Add, Text, x96 y20 w340 h60 , Swept Away 0.3
Gui,2: Font, S8 CDefault, Arial
Gui,2: Add, Text, x36 y100 w380 h60 , Swept Away monitors your applications and minimizes any windows that have been inactive for a user-defined period of time.
Gui,2: Add, Text, x36 y145 w380 h70 , Swept Away is written by Adam Pash and distributed by Lifehacker under the GNU Public License. For detail on how to use Swept Away`, check out the
Gui,2: Font, S8 Cblue Underline, Arial
Gui,2: Add, Text, x116 y175 w170 h30 gHELP, Swept Away homepage
; Generated using SmartGUI Creator 4.0
Gui,2: Show, h225 w459, About Swept Away
Return
DISABLE:
Menu,TRAY,ToggleCheck,%A_ThisMenuItem%
disable := 1 - disable
if disable = 1
{
loop
if disable = 0
break
else
sleep,1000
}
else
Goto,Start
return
READINI:
IfNotExist sweptaway.ini
{
MsgBox,4,Check for Updates?,Would you like Swept Away to automatically check for updates when it's run?
IfMsgBox,Yes
updatereply = 1
else
updatereply = 0
}
sweepTime := GetValFromIni("Preferences","Timer",300)
exclude := GetValFromIni("Preferences","Exclusions","dropcloth.exe,synergys.exe,Workrave.exe,SweptAway.exe,rundll32.exe,sidebar.exe")
update := GetValFromIni("Preferences","UpdateCheck",updatereply)
PollTime := GetValFromIni("Preferences","PollTime",300)
IniWrite,0.3,sweptaway.ini,Preferences,Version
if update = 1
{
SetTimer,UpdateCheck,20000
}
return
GetValFromIni(section, key, default)
{
IniRead,IniVal,sweptaway.ini,%section%,%key%
if IniVal = ERROR
{
IniWrite,%default%,sweptaway.ini,%section%,%key%
IniVal := default
}
return IniVal
}
UpdateCheck:
SetTimer,UpdateCheck,Off
UrlDownloadToFile,http://svn.adampash.com/sweptaway/CurrentVersion.txt,%A_WorkingDir%\VersionCheck.txt
if ErrorLevel = 0
{
FileReadLine, Latest, %A_WorkingDir%\VersionCheck.txt,1
IniRead,Current,sweptaway.ini,Preferences,Version
if Latest != %Current%
{
MsgBox,4,A new version of Swept Away is available!,Would you like to visit the Swept Away homepage and download the latest version?
IfMsgBox,Yes
Run, http://lifehacker.com/software//lifehacker-code-swept-away-windows-255055.php
}
FileDelete,%A_WorkingDir%\VersionCheck.txt ;; delete version check
}
return
RESOURCES:
FileInstall,swept away logo.png,%A_ScriptDir%\sweptaway_logo.png,0
return
EXIT:
ExitApp
return