#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=C:\Dokumente und Einstellungen\christian\Desktop\Altimate Icons 2008-08-13\Icon64.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Comment=FireFox Updater #AutoIt3Wrapper_Res_Description=FireFox Updater #AutoIt3Wrapper_Res_Fileversion=0.99.0.0 #AutoIt3Wrapper_Res_Language=1031 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs Version 3.1 added email on error #ce Opt("TrayIconHide", 0);0=show, 1=hide tray icon #include #include ; userdaten, nur nötig, wenn ein anderer User Verwendet werden soll! ; dazu muss die datei @appdatadir & "\altimate\vpnuser" existieren $u = "vpnuser" ;user $p = "secret :-)" ; passwort $d = @computerName ; domain global $autoit_error_check_string = "END OF FILE REACHED - NO ERROR" #include-once _OnAutoItError() global $takebetas = false; $killifrunning = false; $waitifrunning = False; global $versionlink = "http://releases.mozilla.org/pub/mozilla.org/firefox/releases/" $link = "http://releases.mozilla.org/pub/mozilla.org/firefox/releases/--VERSION--/win32/--LANG--/"; ; some dir, the user has write access ;-) $altimate_home = @appdatadir & "\altimate" global $home = $altimate_home & "\firefox\"; DirCreate($home) status("homedir" & $home,$home); global $server_version global $local_version global $local_lang global $install filedelete($home & "lastresult.txt") status("running",$home) ;; CMD LINE PARAMETER ;; USE PROXY ??? $proxy = ""; $puser = ""; $ppass = ""; $useproxy = false; if($cmdLine[0] > 0) Then if($cmdline[0] < 2) Then msgbox(0,0,"Help:" & @crlf & "-proxy PROXY:PORT" & @crlf & "-proxy-user USER" & @crlf & "-proxy-pass PASSWD" & @crlf & "-proxy my.proxy:3128 -proxy-user john.doe -proxy-pass secret"); endif for $i=1 to ubound($cmdline)-1 ;for ($x in $cmdline) Do $x = $cmdline[$i] if($x ="-proxy") Then $proxy = $cmdline[$i +1] $useproxy = True endif if($x = "-proxy-user") Then $puser = $cmdline[$i +1] $useproxy = True endif if($x = "-proxy-pass") Then $ppass = $cmdline[$i +1] $useproxy = True endif ;if($x = "-data-dir") Then ; $homedir = $cmdline[$i +1] ; $home = $homedir ;endif next if($useproxy = true) then status("using proxy:" & $proxy & " - user:" & $puser & " - pass: " & $ppass,$home) HttpSetProxy(2,$proxy,$puser,$ppass); FtpSetProxy(2,$proxy,$puser,$ppass); endif Else HttpSetProxy(1); FtpSetProxy(1); status("No proxy used", $home) endif ;; / Proxy global $otheruser = false if(isadmin() = false) Then if(fileexists($altimate_home & "\vpnuser")) Then $otheruser = True status("run as other user",$home); endif endif searchversion() status("version searched") if(get_local_version() = false) Then $install = True Else status($server_version & " - " & $local_version) status("pre checkversions") checkversions() endif status($server_version & " - " & $local_version & " - " & $install) if($install == false) Then status("not installing - Exit") ;version exists, exit now... ExiT endif status("installing...") $link = StringReplace($link, "--VERSION--", $server_version); $link = StringReplace($link, "--LANG--",$local_lang); global $versionsetupfile = searchversion_filename(); $versionsetupfile = html_decode($versionsetupfile) $filelink = $link & $versionsetupfile status("starting download-" & $filelink) inetget($filelink, $home & $versionsetupfile) status("got it") ;if ff is running if(ProcessExists("firefox.exe") = false) Then ;if no ff is running -> install update install() status("installed",$home) Else if($waitifrunning) then ;wait for ff to close -> install ProcessWaitclose("firefox.exe") install() status("installed - after wait for close",$home) Else if($killifrunning) Then ;kill ff ->install ProcessClose("firefox.exe") ProcessWaitclose("firefox.exe") install() status("installed - ff killed",$home) Else ; do nothing status("not installed - ff running",$home) endif endif endif func checkversions() status("server_version:" & $server_version) status("local_version:" & $local_version) $serversplit = stringsplit($server_version,".") $localsplit = stringsplit($local_version,".") status("serversplit anzahl:" & $serversplit[0]) status("localsplit anzahl:" & $localsplit[0]) $all_install = false if ($serversplit[1] = $localsplit[1]) then status("serversplit[1] == $localsplit[1]") for $x = 1 to $serversplit[0] status("in split loop; $x=" & $x) if($localsplit[0] >= $x)then status("localsplit[0] >= $x"); $s = $serversplit[$x]; $l = $localsplit[$x]; status("puhh... got $s and $l from arrays") $s = StringStripWS($s,8) $l = StringStripWS($l,8) $s = int($s) $l = int($l) if($s > $l) Then status("$s > $l --> install") $all_install = True Else EndIf Else status("installing because localsplit[0] < $x") $all_install = true; endif Next Else status("$serversplit[1] != $localsplit[1]") if($serversplit[1] > $localsplit[1]) then status("serversplit[1] > $localsplit[1]") $all_install = true Else $all_install = false endif endif if($all_install) Then $install = True Else $install = False endif status("end checkversions") endfunc func get_local_version() $reg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\","CurrentVersion") $v = StringSplit($reg,"(") if($v[0] >= 2) then $local_version = $v[1]; $lang = $v[2]; $local_lang = StringReplace($lang,")",""); return true endif $local_lang = "de"; return false EndFunc func status($text,$home=$home) if(stringlen($text) = 0) Then $text = "-" EndIf filewrite($home & "lastresult.txt", $text & "-" & time() & @crlf) ConsoleWrite($text & "-" & time() & @crlf) endfunc func time() return @year & "-" & @mon & "-" & @mday & "--" & @HOUR & "-" & @MIN & "-" & @SEC endfunc ; searches $versionlink for newest version and takes betas if true func searchversion() $found = 0; $foundstringoben = ""; $searchlink = $versionlink inetget($searchlink, $home & "file") $content = fileread($home & "file") ;filedelete($home & "file") $splits = stringsplit($content, " mail it to me mail_me($sErrorMsg); endif Exit If $sErrorMsg="" Then Exit GUICreate(@ScriptName,385,90,Default,Default,-2134376448);BitOR($WS_CAPTION,$WS_POPUP,$WS_SYSMENU) GUISetBkColor(0xE0DFE2) GUICtrlSetBkColor(GUICtrlCreateLabel("",1,1,383,1),0x41689E) GUICtrlSetBkColor(GUICtrlCreateLabel("",1,88,383,1),0x41689E) GUICtrlSetBkColor(GUICtrlCreateLabel("",1,1,1,88),0x41689E) GUICtrlSetBkColor(GUICtrlCreateLabel("",383,1,1,88),0x41689E) GUICtrlCreateIcon("user32.dll",103,11,11,32,32) GUICtrlSetBkColor(GUICtrlCreateLabel("An error occurred in the application.",52,21,175,15),-2) GUICtrlSetBkColor(GUICtrlCreateLabel("",10,60,110,22),0x706E63) GUICtrlSetState(-1,128) $send=GUICtrlCreateLabel(" send bug report",28,64,92,15) GUICtrlSetBkColor(-1,-2) GUICtrlSetColor(-1,0xFFFFFF) GUICtrlSetCursor(-1,0) $sen=GUICtrlCreateIcon("explorer.exe",254,13,63,16,16) GUICtrlSetCursor(-1,0) GUICtrlSetBkColor(GUICtrlCreateLabel("",124,60,114,22),0xEFEEF2) GUICtrlSetState(-1,128) $show=GUICtrlCreateLabel(" show bug report",143,64,95,15) If @Compiled=0 Then GUICtrlSetData(-1," De-Bug Script") GUICtrlSetBkColor(-1,-2) GUICtrlSetCursor(-1,0) $sho=GUICtrlCreateIcon("shell32.dll",23,127,63,16,16) If @Compiled=0 Then GUICtrlSetImage(-1,"shell32.dll",-81) GUICtrlSetCursor(-1,0) GUICtrlSetBkColor(GUICtrlCreateLabel("",246,8,131,22),0xEFEEF2) GUICtrlSetState(-1,128) $cont=GUICtrlCreateLabel(" continue application",265,12,115,15) GUICtrlSetBkColor(-1,-2) GUICtrlSetCursor(-1,0) $con=GUICtrlCreateIcon("shell32.dll",290,249,11,16,16) GUICtrlSetCursor(-1,0) GUICtrlSetBkColor(GUICtrlCreateLabel("",246,34,131,22),0xEFEEF2) GUICtrlSetState(-1,128) $rest=GUICtrlCreateLabel(" restart application",265,38,115,15) GUICtrlSetBkColor(-1,-2) GUICtrlSetCursor(-1,0) $res=GUICtrlCreateIcon("shell32.dll",255,249,37,16,16) GUICtrlSetCursor(-1,0) GUICtrlSetBkColor(GUICtrlCreateLabel("",246,60,131,22),0xEFEEF2) GUICtrlSetState(-1,128) $close=GUICtrlCreateLabel(" close application",265,64,115,15) GUICtrlSetBkColor(-1,-2) GUICtrlSetCursor(-1,0) $clos=GUICtrlCreateIcon("shell32.dll",240,249,63,16,16) GUICtrlSetCursor(-1,0) GUISetState() WinSetOnTop(@ScriptName,"",1) SoundPlay(@WindowsDir&"\Media\chord.wav") Opt("TrayIconHide",0) Opt("TrayAutoPause",0) TraySetToolTip("AutoIt Error Handler and Debugger") ; choose action to be taken Do $msg=GUIGetMsg() If $msg=$cont Or $msg=$con Then MsgBox(270400,"Continue Application", _ "I am afraid, not possible with AutoIt ! "&@CRLF&@CRLF& _ "( No GoTo command ) :-( ") If $msg=$send Or $msg=$sen Then MsgBox(270400,"Send Bug Report","Email successfully sent ! ") ;#include ; use email ;_INetSmtpMail ( $s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress [,$s_Subject&_ ;[,$as_Body [,$s_helo, [,$s_first [,$b_trace]]]]]) If $msg=$show Or $msg=$sho Then If @Compiled=0 Then __Debug($sErrorMsg) If @Compiled Then MsgBox(270400,"Show Bug Report",$sErrorMsg&" ") EndIf Until $msg=-3 Or $msg=$close Or $msg=$clos Or $msg=$rest Or $msg=$res If $msg=$rest Or $msg=$res Then Run(@AutoItExe&' "'&@ScriptFullPath&'"',@ScriptDir,0,6) Exit EndFunc ;#=#Function#===============================================================# ;# Title .........: __Debug ( $txt ) # ;# Description....: Debug Function for _ErrorHandler.au3 # ;# Parameters.....: $txt = Error Message Text from StdoutRead # ;# Date ..........: 7.9.08 # ;# Authors .......: jennico (jennicoattminusonlinedotde) # ;# @MrCreatoR # ;#==========================================================================# Func __Debug($txt) WinSetState(@ScriptName,"",@SW_HIDE) $a=StringSplit($txt,@CRLF,1) $scitePath=RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe","") Dim $b=StringSplit($a[1],") : ==> ",1),$number=StringMid($b[1],StringInStr($b[1],"(")+1) Dim $code="Error Code: "&@TAB&StringTrimRight($b[2],2),$line="Line: "&@TAB&$number&" => "&$a[3] Dim $file="File: "&@TAB&StringReplace($b[1]," ("&$number,""),$count=StringLen($code),$height=180 If StringLen($file)>$count Then $count=StringLen($file) If StringLen($line)>$count Then $count=StringLen($line) If StringLen($a[2])>$count Then $count=StringLen($a[2]) If $count*6>@DesktopWidth-50 Then Dim $count=(@DesktopWidth-50)/6,$height=240 $pid=Run($scitePath&' "'&@ScriptFullPath&'" /goto:'&$number&","&StringLen($a[2])-1) $x=InputBox(" Please Correct this line:",$code&@CRLF&@CRLF&$file&@CRLF&@CRLF& _ $line,StringTrimRight($a[2],1),"",$count*6,$height) WinSetState(@ScriptName,"",@SW_SHOW) If $x="" Or $x=StringTrimRight($a[2],1) Then Return $t=StringSplit(FileRead(@ScriptFullPath),@CRLF,1) $t[$number]=StringReplace($t[$number],StringTrimRight($a[2],1),$x) $open=FileOpen(@ScriptFullPath,2) For $i=1 to $t[0] FileWriteLine($open,$t[$i]) Next FileClose($open) ControlSend(@ScriptDir,"","ToolbarWindow32","^R") EndFunc ;#=#INDEX#==================================================================# ;# Title .........: AutoIt3 Error Handler & Debugger Example Script # ;# Date ..........: 7.9.08 # ;# Author ........: jennico (jennicoattminusonlinedotde) # ;#==========================================================================# func mail_me($text) #cs ; Diesen Block aktivieren, Server und E-Mail adresse anpassen, dann ist das Logging per E-Mail im Fehlerfall aktiv! $s_SmtpServer = "gmail-smtp-in.l.google.com" $s_FromName = "MySelf - daef" $s_FromAddress = "daef_ff_updater@blank-online.eu" $s_ToAddress = "blank.chef@googlemail.com" $s_Subject = "ff updater error" Dim $as_Body[2] $as_Body[0] = $text $as_Body[1] = "user: " & @UserName; $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body,"",-1) #ce endfunc func OnAutoItExit() ConsoleWrite($autoit_error_check_string); EndFunc