#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=icons\chat_blank.ico #AutoIt3Wrapper_outfile=talker.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ================================================================================================================ ; LANGUAGE OPTIONS Opt("TrayMenuMode",1) AutoItSetOption("MustDeclareVars", 0) ; ================================================================================================================ ; INCLUDES (update as needed) #Include #Include #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) $sAppDesc = "Utility for text to speech for use in batch scripting" $sAppName = "Talker" $sAppAuthor = "Sean Shrum" $sAppVersion = "2.02" $sAppEmail = StringLower($sAppName)& "@shrum.net" $sAppHome = "http://www.shrum.net/sean/code/" & StringLower($sAppName) $sAppNews = $sAppHome & "/updates.html" $sAppSupport = $sAppHome & "/support.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 Global $bDebug=False, $bVerbose ; ================================================================================================================ ; 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\" & $sAppName & "\" & $sAppName & ".lnk") FileCreateShortcut($sAppHome, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\Homepage.lnk") FileCreateShortcut($sAppSupport, @ProgramsCommonDir & "\shrum.net\Support.lnk") FileCreateShortcut(@ScriptFullPath, @UserProfileDir & "\application data\microsoft\Internet Explorer\Quick Launch\" & $sAppName & ".lnk") EndIf ; ================================================================================================================ ; SYSTRAY MENU DEFINITIONS (if any) TrayCreateItem ("[ Project ]") $mAbout = TrayCreateItem ("...About") TrayItemSetState (-1, $TRAY_DEFAULT) $mUpdate = TrayCreateItem ("...Update") $mHomepage = TrayCreateItem ("...Homepage") $mNews = TrayCreateItem ("...News") $mSupport = TrayCreateItem ("...Support") $mDebug = TrayCreateItem ("...Debug") $mExit = TrayCreateItem ("...Exit") TraySetState () TraySetClick (16) ; ================================================================================================================ ; 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] = 0 Then _CommandLineBuilder() else for $i = 1 to $CmdLine[0] _TalkOBJ($CmdLine[$i]) Next EndIf ; ================================================================================================================ ; FUNCTIONS Func _AboutDialog() _ConsoleWrite("+ _AboutDialog()") $iResult = msgbox(4,"About", $sAppTitle & " ( build " & $sAppBuild & " )" & @CRLF & @CRLF & _ $sAppDesc & @CRLF & @CRLF & _ "Would you like to visit the " & $sAppName & " web site for more information about this utility?") If $iResult = 6 Then ShellExecute($sAppHome) _ConsoleWrite("- _AboutDialog()") EndFunc Func _CommandLineBuilder() GuiCreate($sAppName & " v." & $sAppVersion & " - Builder mode", 341, 150,(@DesktopWidth-341)/2, (@DesktopHeight-150)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Label_1 = GuiCtrlCreateLabel("Text to say:", 10, 10, 320, 20) $oText = GuiCtrlCreateInput("", 10, 30, 320, 20) $oShortcut = GuiCtrlCreateButton("Make &shortcut", 10, 70, 100, 30) $oSay = GuiCtrlCreateButton("&Talk", 120, 70, 100, 30) $oCancel = GuiCtrlCreateButton("&Cancel", 230, 70, 100, 30) $oHomepage = GuiCtrlCreateButton("Home&page", 10, 110, 100, 30) $oSupport = GuiCtrlCreateButton("&Support", 120, 110, 100, 30) $oUpdate = GuiCtrlCreateButton("&Update", 230, 110, 100, 30) GUICtrlSetState($oText, $GUI_FOCUS) GUICtrlSetState($oSay, $GUI_DEFBUTTON) GuiSetState() WinActivate($sAppTitle & " - Builder mode") While 1 $msg = GuiGetMsg() Select case $msg = $oShortcut FileCreateShortcut(@ScriptFullPath, @DesktopDir & "\" & $sAppName & " - '" & GUICtrlRead($oText) & "'.lnk",@ScriptDir,'"' & GUICtrlRead($oText) & '"',$sAppName & ' "' & GUICtrlRead($oText) & '"') msgbox(64,$sAppTitle,"A shortcut has been created on your desktop.",10) case $msg = $oSay _TalkOBJ(GUICtrlRead($oText)) case $msg = $oHomepage _ShellExecute($sAppHome) case $msg = $oSupport _ShellExecute($sAppSupport) case $msg = $oUpdate _UpdateCheck() case $msg = $oCancel Exit Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd GUIDelete() EndFunc func _ConsoleWrite($sMsg) _DebugOut($sMsg) Consolewrite($sMsg & @CRLF) EndFunc Func _DefineSetting($sSetting="", $sValue="") _consolewrite("+ _DefineSetting()") _ConsoleWrite(": Setting '" & $sSetting & "' = '" & $sValue & "'") if $sSetting = "" or $sSetting = "Debug" Then if $sValue then $bDebug = $sValue Else if not $bDebug then $bDebug = True Else $bDebug = False EndIf endif if $bDebug Then _DebugSetup($sAppTitle & " - debugging info") _ConsoleWrite("Debug console :: " & $sAppTitle & " :: build " & $sAppBuild) _ConsoleWrite("========================[ START ]=============================") opt("TrayIconDebug",1) TrayItemSetState($mDebug,1) Else _ConsoleWrite("=========================[ END ]==============================") opt("TrayIconDebug",0) TraySetToolTip($sAppTitle) TrayItemSetState($mDebug,4) EndIf EndIf _consolewrite("- _DefineSetting()") EndFunc func _MenuMonitor() $msg = TrayGetMsg () Select Case $msg = $TRAY_EVENT_PRIMARYDOWN _AboutDialog() Case $msg = $mAbout _AboutDialog() Case $msg = $mDebug _DefineSetting("Debug", Not $bDebug) case $msg = $mUpdate _UpdateCheck() case $msg = $mHomepage _ShellExecute($sAppHome) case $msg = $mNews _ShellExecute($sAppNews) case $msg = $mSupport _ShellExecute($sAppSupport) case $msg = $mUpdate _UpdateCheck() 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 _ShellExecuteWait($sCmd) _ConsoleWrite("+ _ShellExecuteWait()") if $sCmd = "" Then _ConsoleWrite(": No command passed") Else _ConsoleWrite(": Running '" & $sCmd & "'") ShellExecuteWait($sCmd) EndIf _ConsoleWrite("- _ShellExecuteWait()") endfunc Func _TalkOBJ($s_text) Local $o_speech $o_speech = ObjCreate("SAPI.SpVoice") $o_speech.Speak($s_text) $o_speech = "" 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