#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=icons\Get Info (2).ico #AutoIt3Wrapper_outfile=ezpcdets.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ================================================================================================================ ; LANGUAGE OPTIONS Opt("TrayMenuMode",3) AutoItSetOption("MustDeclareVars", 0) ; ================================================================================================================ ; INCLUDES (update as needed) #Include #include #include ; ================================================================================================================ ; 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 = "Ezpcdets" $sAppDesc = "SysTray icon for PC name / IP address lookups" $sAppAuthor = "Sean Shrum" $sAppVersion = "2.20" $sAppEmail = StringLower($sAppName)& "@shrum.net" $sAppHome = "http://www.shrum.net/sean/code/" & StringLower($sAppName) $sAppNews = $sAppHome & "/updates.html" $sAppSupport = "http://www.shrum.net/cats.php?dir=/sean/code/" & StringLower($sAppName) & "&body=/sean/support.shtml" $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 Global $bDebug=False, $bVerbose Global $sMsg, $sWANIP, $sWANURL = "http://www.shrum.net/sean/remote_addr.php" ; ================================================================================================================ ; 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,$sAppDesc,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\sean\code\" & $sAppName & "\" & $sAppName & ".lnk") FileCreateShortcut($sAppHome, @ProgramsCommonDir & "\shrum.net\sean\code\" & $sAppName & "\Homepage.lnk") FileCreateShortcut(@ScriptFullPath, @UserProfileDir & "\application data\microsoft\Internet Explorer\Quick Launch\" & $sAppName & ".lnk") EndIf ; ================================================================================================================ ; SYSTRAY MENU DEFINITIONS (if any) TrayCreateItem ("[ Ezpcdets ]") $mInfo = TrayCreateItem ("...Info") TrayItemSetState (-1, $TRAY_DEFAULT) TrayCreateItem ("") TrayCreateItem ("[ Project ]") $mAbout = TrayCreateItem ("...About") $mHomepage = TrayCreateItem ("...Homepage") $mNews = TrayCreateItem ("...News") $mSupport = TrayCreateItem ("...Support") $mUpdate = TrayCreateItem ("...Check for update") $mExit = TrayCreateItem ("...Exit") TraySetState () TraySetClick (16) ; ================================================================================================================ ; HOTKEY DEFINITIONS (if any) _HotkeySet() ; ================================================================================================================ ; MAIN PROGRAM $sWANIP = _INetGetSource($sWANURL) TraySetToolTip("LAN1=" & @IPAddress1 & " \ WAN=" & $sWANIP ) While 1 _MenuMonitor() WEnd ; ================================================================================================================ ; FUNCTIONS Func _AboutDialog() _ConsoleWrite("+ _AboutDialog()") msgbox(0,"About", $sAppTitle & " ( build " & $sAppBuild & " ) by " & $sAppAuthor & @crlf & $sAppHome & " :: " & StringLower($sAppName) & "@shrum.net") _ConsoleWrite("- _AboutDialog()") EndFunc func _ConsoleWrite($sMsg) _DebugOut($sMsg) Consolewrite($sMsg & @CRLF) EndFunc Func _DefineSetting($sSetting="", $sValue="") _consolewrite("+ _DefineSetting()") _ConsoleWrite(": Setting '" & $sSetting & "' = '" & $sValue & "'") _consolewrite("- _DefineSetting()") EndFunc func _DisplayInfo() $sSysDriveFree = DriveSpaceFree("C:") $SSysDriveSize = DriveSpaceTotal("c:") $aSysMemFree = MemGetStats() TrayTip($sAppTitle, "[" & @LogonDomain & "] \ " & @ComputerName & " \ " & @UserName & " on " & @OSVersion & " " & @OSServicePack _ & "SysDrive=" & round($sSysDriveFree/1000000, 1) & "TB free / " & round($SSysDriveSize/1000000, 1) & "TB total " & @CRLF _ & "SysMem=" & $aSysMemFree[$MEM_LOAD] & "% load / " & round($aSysMemFree[$MEM_TOTALPHYSRAM]/1000000, 1) & "GB total",30) EndFunc Func _Exit() _ConsoleWrite("+ _Exit()") Exit EndFunc func _HotkeySet() _ConsoleWrite("+ _HotkeySet()") hotkeyset("!^#i", "_DisplayInfo") _ConsoleWrite("- _HotkeySet()") EndFunc func _MenuMonitor() $msg = TrayGetMsg () Select Case $msg = $TRAY_EVENT_PRIMARYDOWN _DisplayInfo() Case $msg = $mInfo _DisplayInfo() Case $msg = $mAbout _AboutDialog() case $msg = $mUpdate _UpdateCheck() case $msg = $mHomepage _ShellExecute($sAppHome) case $msg = $mSupport _ShellExecute($sAppSupport) case $msg = $mNews _ShellExecute($sAppNews) case $msg = $mExit _Exit() EndSelect EndFunc Func _ShellExecute($sCmd) _ConsoleWrite("+ _ShellExecute()") if $sCmd = "" Then _ConsoleWrite(": No command passed") Else _ConsoleWrite(": Running '" & $sCmd & "'") shellExecute($sCmd) EndIf _ConsoleWrite("- _ShellExecute()") endfunc func _UpdateCheck() _ConsoleWrite("+ _UpdateCheck()") $sTemp = "" $aTemp = stringsplit(_InetGetSource($sAppHome & "/" & stringlower($sAppName) & ".au3"), @CRLF) For $i = 1 to $aTemp[0] if StringInStr($aTemp[$i], "$sAppVersion") then $sTemp = $aTemp[$i] ExitLoop endif Next if $sTemp <> "" then $aOnlineVersion = StringSplit($sTemp, "=") $sOnlineVersion = StringReplace(StringStripWS($aOnlineVersion[2], 8), '"', "") _ConsoleWrite(": Online = " & $sOnlineVersion) _ConsoleWrite(": User = " & $sAppVersion) if $sOnlineVersion <> "" and Not Stringinstr($sOnlineVersion, "") Then If $sAppVersion < $sOnlineVersion Then _ConsoleWrite(": User is OLDER") $sMsg = "A newer version of this program is available for download." & @CRLF & @CRLF $sMsg &= "Do you want to visit the " & $sAppname & " site to download v." & $sOnlineVersion & "?" & @CRLF & @CRLF $sMsg &= "Selecting 'Yes' will close this app and take you to the website." If MsgBox(4, $sAppTitle, $sMsg) = 6 Then _ConsoleWrite(": Launching default web browser to " & $sAppHome) _ShellExecute($sAppHome) Exit EndIf ElseIf $sAppVersion >= $sOnlineVersion Then _ConsoleWrite(": User is UP-TO-DATE") TrayTip($sAppTitle, "Your version is up-to-date.",5) EndIf Else _ConsoleWrite(": Data received but no version info found") traytip($sAppTitle,"Unable to locate versioning info in data received." & @CRLF & "Please go to the homepage for further update details.",5) EndIf Else _ConsoleWrite(": Unable to obtain version content") traytip($sAppTitle,"Unable to obtain online version info." & @CRLF & "Check your connection and try again.",5) EndIf _ConsoleWrite("- _UpdateCheck()") EndFunc