#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=icons\ichat.ico #AutoIt3Wrapper_Outfile=prompter.exe #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ================================================================================================================ ; 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) $sAppDescription = "User definable Windows message box prompt; launches " & @CRLF & "defined commandlines based on user response" $sAppName = "Prompter" $sAppAuthor = "Sean Shrum" $sAppVersion = "2.03" $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 $sTitle, $sPrompt, $sY, $sN, $sO, $sC, $sR, $sA, $sI, $sX, $iExpiration, $iResult, $iFlag, $sCmdLine $sTitle = $sAppTitle $iFlag = 0 $sY = "" ; yes $sN = "" ; no $sO = "" ; ok $sC = "" ; cancel $sR = "" ; retry $sA = "" ; abort $sI = "" ; ignore $sX = "" ; close/timeout ; ================================================================================================================ ; 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) ; FIRST TIME PROGRAM RUN / PROGRAM GROUP CREATION ======================================================== $iRunCount = RegRead("HKEY_LOCAL_MACHINE\software\shrum.net\" & $sAppName, "executed") If $iRunCount = "" Then DirCreate(@ProgramsCommonDir & "\shrum.net\" & $sAppName) FileCreateShortcut(@ScriptFullPath, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\" & $sAppName & ".lnk") FileCreateShortcut(@ScriptFullPath, @UserProfileDir & "\application data\microsoft\Internet Explorer\Quick Launch\" & $sAppName & ".lnk") FileCreateShortcut($sAppHome, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\Homepage.lnk") FileCreateShortcut($sAppSupport, @ProgramsCommonDir & "\shrum.net\Support.lnk") EndIf ; ARGUMENT COLLECTION ==================================================================================== if $CmdLine[0] = 0 Then $iResult = MsgBox(4,$sAppTitle, $sAppTitle & " (" & $sAppBuild & ")" & @CRLF & _ $sAppHome & @CRLF & _ $sAppAuthor & " (" & $sAppEmail & ")" & @CRLF & @CRLF & _ $sAppDescription & @CRLF & @CRLF & _ "+ Msgbox params:" & @CRLF & @CRLF & _ " [T]itle = Window title" & @CRLF & _ " [P]rompt = Prompt text" & @CRLF & _ " [E]xpiration = Msgbox expiration (in sec); optional" & @CRLF & _ " [F]lag = Msgbox decimal flag" & @CRLF & @CRLF & _ "+ Button params (cmdlines to run when pressed):" & @CRLF & @CRLF & _ " [A] = Abort commandline" & @CRLF & _ " [C] = Cancel commandline" & @CRLF & _ " [I] = Igrone commandline" & @CRLF & _ " [N] = No commandline" & @CRLF & _ " [O] = Ok commandline" & @CRLF & _ " [R] = Retry commandline" & @CRLF & _ " [X] = Dialog close/timeout commandline" & @CRLF & _ " [Y] = Yes commandline" & @CRLF & @CRLF & _ "Remember to wrap cmdlines with spaces in dbl-quotes." & @CRLF & @CRLF & _ "Would you like to visit the Prompter web site?") If $iResult = 6 Then ShellExecute($sAppHome) Exit else for $i = 1 to $CmdLine[0] $aParam = StringSplit($CmdLine[$i], "=") $sParam = StringUpper(stringleft($aParam[1],1)) Select case $sParam = "A"; Abort Cmd $sA = $aParam[2] case $sParam = "C"; Cancel Cmd $sC = $aParam[2] Case $sParam = "E"; Expiration $iExpiration = $aParam[2] case $sParam = "F"; Flag $iFlag = $aParam[2] case $sParam = "I"; Ignore Cmd $sI = $aParam[2] case $sParam = "N"; No Cmd $sN = $aParam[2] case $sParam = "O"; Ok Cmd $sO = $aParam[2] case $sParam = "P"; Prompt $sPrompt = $aParam[2] case $sParam = "R"; Retry Cmd $sR = $aParam[2] Case $sParam = "T"; Title $sTitle = $aParam[2] case $sParam = "X"; 'x' Close/timeout Cmd $sX = $aParam[2] case $sParam = "Y"; Yes Cmd $sY = $aParam[2] EndSelect Next EndIf $iResult = MsgBox($iFlag,$sTitle,$sPrompt,$iExpiration) If @error And $sX <> "" Then $sCmdLine = $sX Else Select Case $iResult = 1 $sCmdLine = $sO Case $iResult = 2 $sCmdLine = $sC Case $iResult = 3 $sCmdLine = $sA Case $iResult = 4 $sCmdLine = $sR Case $iResult = 5 $sCmdLine = $sI Case $iResult = 6 $sCmdLine = $sY Case $iResult = 7 $sCmdLine = $sN EndSelect EndIf If $sCmdLine <> "" Then ShellExecute($sCmdLine)