#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=icons\Delete (2).ico #AutoIt3Wrapper_outfile=killapps.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $sAppVersion = "2.00" ; ================================================================================================================ ; LANGUAGE OPTIONS Opt("TrayMenuMode",1) AutoItSetOption("MustDeclareVars", 0) ; ================================================================================================================ ; INCLUDES (update as needed) ; N/A ; ================================================================================================================ ; DUPLICATE INSTANCE CHECK (may need to remove or move this around depending on where it is needed) If UBound(ProcessList(@ScriptName)) > 2 Then Exit ; ================================================================================================================ ; SCRIPT IDENTITY (this is based on the filename of the script/executable) $sAppName = stringupper(stringleft(@scriptname,1)) & StringTrimLeft(stringtrimright(@scriptname,4),1) $sAppAuthor = "Sean Shrum" $sAppEmail = StringLower($sAppName)& "@shrum.net" $sAppHome = "http://www.shrum.net/sean/code/" & StringLower($sAppName) $sAppNews = $sAppHome & "/updates.html" $sAppFileType ="." & StringLower($sAppName) $aAppBuild = FileGetTime(@ScriptFullPath) $sAppBuild = $aAppBuild[0] & "." & $aAppBuild[1] & "." & $aAppBuild[2] & " @ " & $aAppBuild[3] & ":" & $aAppBuild[4] & ":" & $aAppBuild[5] $sAppTitle = $sAppName & " v." & $sAppVersion $sAppSettings = "HKCU\software\shrum.net\" & $sAppName ; ================================================================================================================ ; VARIABLE DECLARATIONS / DEFAULTS ; N/A ; ================================================================================================================ ; TRAY ICON AND TOOLTIP SET (looks for .ico in same folder as .exe otherwise uses the build icon) TraySetToolTip($sAppTitle) TraySetIcon($sAppName & ".ico") ; ================================================================================================================ ; SPLASH SCREEN / TRAYTIP BUBBLE (*only* if no command line params are present: automated run/batch call) if $CmdLine[0] = 0 Then Traytip($sAppTitle,$sAppHome & @CRLF & "By " & $sAppAuthor & " :: " & $sAppEmail,5) ; ================================================================================================================ ; REGISTRY UPDATES (location, version, runcount) $iRunCount = RegRead($sAppSettings, "Executed") RegWrite($sAppSettings, "Executed", "REG_SZ", $iRunCount + 1) RegWrite($sAppSettings, "", "REG_SZ", @Scriptdir) RegWrite($sAppSettings, "Version", "REG_SZ", $sAppVersion) ; ================================================================================================================ ; PROGRAM GROUP / SHORTCUTS CREATION (fires only when Executed reg value = "" from above) If $iRunCount = "" Then DirCreate(@ProgramsCommonDir & "\shrum.net\" & $sAppName) FileCreateShortcut(@ScriptFullPath, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\" & $sAppName & ".lnk") FileCreateShortcut($sAppHome, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\Homepage.lnk") FileCreateShortcut(@ScriptFullPath, @UserProfileDir & "\application data\microsoft\Internet Explorer\Quick Launch\" & $sAppName & ".lnk") EndIf ; ================================================================================================================ ; SYSTRAY MENU DEFINITIONS (if any) ; N/A ; ================================================================================================================ ; LAST RUN SETTINGS LOAD ; N/A ; ================================================================================================================ ; COMMAND-LINE / .INI EVALUATION ; N/A ; ================================================================================================================ ; ARGUMENT CHECKS / PROMPTS ; N/A ; ================================================================================================================ ; SETTINGS SAVE (all user passed params should be formatted to program-desired formats by this point) ; N/A ; ================================================================================================================ ; HOTKEY DEFINITIONS (if any) ; N/A ; ================================================================================================================ ; DEBUG WINDOW (notepad; if requested) ;N/A ; ================================================================================================================ ; MAIN PROGRAM if $cmdline[0] < 1 Then $var = WinList() For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then if $var[$i][0] <> "Killapps" AND $var[$i][0] <> "Program Manager" then ProcessClose(WinGetProcess($var[$i][0])) EndIf endif Next Else ProcessClose(ProcessExists($cmdline[1])) EndIf ; ================================================================================================================ ; FUNCTIONS Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc