AutoHotkey Community

It is currently May 26th, 2012, 4:57 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: February 4th, 2009, 1:44 pm 
Offline

Joined: January 20th, 2007, 1:29 pm
Posts: 96
Location: Melbourne
I got fed up hunting through folders always updating my ftp with different exe files, so now i can leave them in my sourcecode folders and this GUI checks them against server versions and uploads them from one location, stores the info in its ini file and uploads a cut down ini file to your ftp which you can use for Update checks with code written into your programs.
as u can see, it also uploads zips and pics. it also handles all / in remote paths correctly, so leading and trailing / are automatically fixed.

ImageImage


Code:
;
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         Trubbleguy
;
; Script Function:
;   Update your Ftp fast and easy
;
;make your Code create a files.txt with any files you want to Update from downloaded update.ini
;Put the following into any program you write changing the exe names of course
;
;START PROGRAM UPDATE STUFF
;neededfiles=
;(
;NewFrontend.exe            
;Accessbookcreator.exe
;Updater.exe
;wav.exe
;bookprint.mdb
;)
;;you can update any File , as you can see im watching a bookprint.mdb as well

;Ifexist %A_ScriptDir%\files.txt
;filedelete,%A_ScriptDir%\files.txt
;fileappend,%neededfiles%,%A_ScriptDir%\files.txt
;;also as Updater cant update its self
;IfExist,%A_ScriptDir%\Updater.src
;{
;   FileDelete,%A_ScriptDir%\Updater.exe
;   FileMove,%A_ScriptDir%\Updater.src,%A_ScriptDir%\Updater.exe
;}
;END PROGRAM UPDATE STUFF
;
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance Force
Onexit,GuiClose
IniRead,FtpHost,%A_ScriptDir%\ftpdetails.ini,server,server,ftp.yourserver.com  ;you can set defaults with the last variable of each line if no ini file
IniRead,FtpPort,%A_ScriptDir%\ftpdetails.ini,port,port,21
IniRead,FtpUsername,%A_ScriptDir%\ftpdetails.ini,username,username ,yourusername
IniRead,FtpPassword,%A_ScriptDir%\ftpdetails.ini,password,password ,yourpassword

local_ini=%A_ScriptDir%\uploader.ini ;local file with all exe's listed and their versions
remote_ini=%A_ScriptDir%\update.txt ; a single file to put on your ftp with ALL your version info for auto updates in sofware

Gui, Font, s9
Gui, Add, Tab, vTabz w430 h360 AltSubmit -Wrap  ,Programs|Upload|

Gui, Tab, Programs
   Gui, Add, Text,x128 y12 w260 r1 , Double click a file to Edit details or Manually Upload
   Gui, Add, ListView,x14 y32 w415 h300 vlist3 BackgRoundFFFFF9 AltSubmit grid gListBoxClick Checked ,FileName|Local Version|Remote Version|Remote Path|Full Local Path/Name|Name only|Info | |
   Gui, Add, Button,x14 y+3 w100 r1 gaddprog ,Add Program
   Gui, Add, Button,x+10 yp w100 r1 gdelprog ,Delete Program
   Gui, Add, Button,x+10 yp w100 r1 gautoupload ,Upload (AUTO)

Gui, Tab, Upload
   Gui, Add, Text,x14 y32 w100 r1 ,Filename
   Gui, Add, Text,vw1 x+2 yp w120 r1
   Gui, Add, Text,x+2 yp w60 r1 , size in K
   Gui, Add, Text,vsz x+2 yp w100 r1 ,
   Gui, Add, Text,x14 y+2 w100 r1 ,Local Version
   Gui, Add, Text,vw2 x+2 yp w320 r1
   Gui, Add, Text,x14 y+2 w100 r1 ,Version on Ftp
   Gui, Add, Text,vw3 x+2 yp w320 r1
   Gui, Add, Text,x14 y+6 w100 r1,  %FtpHost% /
   Gui, Add, Edit,vw4 x+2 yp w320 r1
   Gui, Add, Button,x14 y+2 w100 r1 gmanual,UPLOAD NOW
   Gui, Add, Button,x+26 yp w100 r1 gut,Save INFO in ini
   Gui, Add, Text,x14 y+5 w300 r1,Type Updated INFO for this updated prog below   ;eg what changes you made to the code etc...
   Gui, Add, Edit,T WantTab vvinfo -Wrap x14 y+1 w415 r16 BackgRoundFFFFF9,%vinfo%

Gui,Add,StatusBar,,
Gui,Show, AutoFit
gosub read

return
;########################################################################################## END MAIN LOOP
;##########################################################################################
;##########################################################################################
;##########################################################################################
;########################################################################################## START OF SUBS
autoupload:
Gui,Submit,Nohide  ;get any changes to forms
checkedrecord:=LV_GetNext("","Checked") ;are there any records checked
if not checkedrecord
{
   SB_SetText( "Nothing to Upload ")
   return
}   
StartTime := A_TickCount
Gosub ftpconnect
     If (FtpConnection != 1)  ;if no connection bomb out
     return

Loop % LV_GetCount()
   {   
   if A_index <> %checkedrecord%
   continue
   loop 5
   c%A_Index%=
   checkedrecord:=LV_GetNext(checkedrecord,"Checked")
         LV_GetText(c1, A_Index,1)
         LV_GetText(c2, A_Index,2)
         LV_GetText(c3, A_Index,3)
         LV_GetText(c4, A_Index,4)
         LV_GetText(c5, A_Index,5)
         LV_GetText(c6, A_Index,6)
         localFile=%c5%
         LV_Modify(A_Index,"-Check")
         if c4 
            {
            stringleft,sl,c4,1   ;checking for / on both ends of string....
            stringright,sr,c4,1
            if sl=/   
            stringtrimleft,c4,c4,1
            if sr=/   
            stringtrimright,c4,c4,1
            remoteFile=%c4%/%c1%
            }
         else
            remoteFile=%c1%
         gosub Uploadfile
      
   Iniwrite,%c4%,%local_ini%,%C6%,path
   Iniwrite,%c2%,%local_ini%,%C6%,version
   vinfo:=%c6%info
   Iniwrite,%vinfo%,%local_ini%,%c6%,vinfo

   Iniwrite,%c4%,%remote_ini%,%C6%,path      ;path on your server to store updated file
   Iniwrite,%c2%,%remote_ini%,%c6%,version    ;this is the version of file to send to server
   Iniwrite,%vinfo%,%remote_ini%,%c6%,vinfo   ;this is the Info on the updates to send to server
   }
localFile=%A_ScriptDir%\Update.txt ;send the update.txt file to FTP
remoteFile=Update.txt

gosub uploadfile
FtpClose()
Gosub tm     ;post finish time
changes=
Return


manual:
StartTime := A_TickCount
gui,submit,nohide
if w4 ;check if data was put in path box in tab 2
c4:=w4  ;update c4 with path data from tab 2
;If c2 = %c3%   ;checks if already updated    you can un-rem this to bomb out if already done
;return
Gosub ftpconnect
     If (FtpConnection != 1)  ;if no connection bomb out
     return
localFile=%c5%
if c4 
   {
   stringleft,sl,c4,1   ;checking for / on both ends of string....
   stringright,sr,c4,1
   if sl=/   
   stringtrimleft,c4,c4,1
   if sr=/   
   stringtrimright,c4,c4,1
   remoteFile=%c4%/%c1%
   }
else
   remoteFile=%c1%
gosub Uploadfile
   StringReplace,vinfo,vinfo,`n,~,all  ;make the info a single line again
   Iniwrite,%w4%,%local_ini%,%C6%,path
   Iniwrite,%c2%,%local_ini%,%C6%,version
   Iniwrite,%vinfo%,%local_ini%,%C6%,vinfo
   
   Iniwrite,%w4%,%remote_ini%,%C6%,path       ;this is the Update.txt file to send to server
   Iniwrite,%c2%,%remote_ini%,%C6%,version    ;this is the Update.txt file to send to server
   Iniwrite,%vinfo%,%remote_ini%,%C6%,vinfo   ;this is the Update.txt file to send to server

localFile=%A_ScriptDir%\Update.txt ;send the update.txt file to FTP
remoteFile=Update.txt
gosub uploadfile
FtpClose()
Gosub tm     ;post finish time
changes=
gosub read
return
;##########################################################################################
ut:
gui,submit,nohide
   StringReplace,vinfo,vinfo,`n,~,all  ;make the info a single line again
   Iniwrite,%w4%,%local_ini%,%C6%,path
   Iniwrite,%c2%,%local_ini%,%C6%,version
   Iniwrite,%vinfo%,%local_ini%,%C6%,vinfo
   
   Iniwrite,%w4%,%remote_ini%,%C6%,path
   Iniwrite,%c2%,%remote_ini%,%C6%,version    ;this is the Update.txt file to send to server
   Iniwrite,%vinfo%,%remote_ini%,%C6%,vinfo   ;this is the Update.txt file to send to server
changes++  ;make sure changes will be saved on exit if forgotten
if changes >1
  SB_SetText( changes " modifications saved " )
else
  SB_SetText( changes " modification saved " )
return
;##########################################################################################
sendtxt:
if not changes   ;makes sure no changes are missed on server
Return
Gosub ftpconnect
     If (FtpConnection != 1)  ;if no connection bomb out
     return
localFile=%A_ScriptDir%\Update.txt ;send the update.txt file to FTP
remoteFile=Update.txt
gosub uploadfile
FtpClose()
changes=
return
;##########################################################################################
tm:
ElapsedTime := round((A_TickCount - StartTime) / 1000)
SB_SetText( "Upload Time " FormatSeconds(ElapsedTime) )
changes=
return
;##########################################################################################
FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time = 19990101  ; *Midnight* of an arbitrary date.
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
    return NumberOfSeconds//3600 ":" mmss  ; This method is used to support more than 24 hours worth of sections.
}
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ftpconnect:
      SB_SetText( "Connecting to " FtpHost )
 FtpConnection := FtpOpen(FtpHost, FtpPort, FtpUsername, FtpPassword)
   If (FtpConnection != 1)
   {
      concount++
      if concount<4   ;try 4 times
      goto ftpconnect
      else
      SB_SetText( "Error Connecting to" FtpHost )
      return
     }
   else   
      SB_SetText( "Connected to " FtpHost )
 Return
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 downloadFile:
  If (FtpConnection != 1)
  return
   ; retrieve file from FTP server
      SB_SetText( "Downloading file " remoteFile )
   fileTransfer := FtpGetFile(remoteFile, localFile)
   If (fileTransfer != 1)
      {
      SB_SetText( "Error downloading file " remoteFile )
      Sleep 2000
       exitapp
        }
Return
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
uploadFile:
  If (FtpConnection != 1)
  return
 
   ; store file on FTP server
   SB_SetText( "Uploading file " localFile " to " remoteFile)
   fileTransfer := FtpPutFile(localFile, remoteFile)
   If (fileTransfer != 1)
         {
         SB_SetText( "Error uploading file " localFile )
      Sleep 2000
        }
     else
   {        
      SB_SetText( "Uploading Complete " localFile )
      FormatTime, TimeString, %A_Now%, dddd MMMM d, yyyy hh:mm:ss tt
      fileappend,%TimeString% %A_Tab% %localfile%`n ,%A_ScriptDir%\uploadlog.txt
      update++   ; a file got uploaded.....
    }
Return
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GuiClose:
gosub sendtxt
Exitapp
Return
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
addprog:
OutNameNoExt=
OutFileName=
afver=
rver=
rpath=
addedfile=
info=
FileSelectFile,addedfile,1,%A_ScriptDir%,select your File,
If Errorlevel
return
if exelist contains %addedfile%
return
exelist.= addedfile "~"
Iniwrite,%exelist%,%local_ini%,exelist,list
SplitPath, addedfile , OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
if OutExtension = exe
fileGetVersion,afver,%addedfile%
else
   {
   FileGetTime, afver ,%addedfile%,M
   stringleft,afver,afver,8
   }
FileGetSize,%OutNameNoExt%sz,%addedfile%,K
LV_Add(" ", OutFileName , afver, rver , rpath , addedfile , OutNameNoExt, info)
LV_ModifyCol(1,130)
LV_ModifyCol(2,90)
LV_ModifyCol(3,90)
LV_ModifyCol(4,100)
LV_ModifyCol(5)
LV_ModifyCol(6)
changes++
Return
;##########################################################################################
delprog:
   cc1=
   cc2=
   FocusedRowNumber := LV_GetNext(0, "F")  ; Find the Focused row.
   If not FocusedRowNumber  ; No row is Focused.
      Return
   LV_GetText(cc1, FocusedRowNumber,5)
   LV_GetText(cc2, FocusedRowNumber,6)
loop,parse,exelist,~,`r`n
{
if not A_LoopField
continue   
if A_LoopField=%cc1%
continue
newexelist.= A_LoopField "~"
}
Iniwrite,%newexelist%,%local_ini%,exelist,list
IniDelete, %local_ini%, %cc2%
changes++
newexelist=
gosub read
Return
;##########################################################################################
ListBoxClick:
   If A_GuiControlEvent = DoubleCLick
         {
            loop 6
            c%A_Index%=
         FocusedRowNumber := LV_GetNext(0, "F")  ; Find the Focused row.
                  If not FocusedRowNumber  ; No row is Focused.
               Return
         LV_GetText(c1, FocusedRowNumber,1)
         LV_GetText(c2, FocusedRowNumber,2)
         LV_GetText(c3, FocusedRowNumber,3)
         LV_GetText(c4, FocusedRowNumber,4)
         LV_GetText(c5, FocusedRowNumber,5)
         LV_GetText(c6, FocusedRowNumber,6)
         GuiControl, Choose, Tabz, 2
         GuiControl,,w1,%c1%
         GuiControl,,w2,%c2%
         GuiControl,,w3,%c3%
         GuiControl,,w4,%c4%
         sz:=%c6%sz
         GuiControl,,sz,%sz%
         vinfo:=%c6%info
         if vinfo=ERROR
         {
         GuiControl,,vinfo,
         Return
         }
         stringreplace,vinfo,vinfo,~,`n,all
         GuiControl,,vinfo,%vinfo%
      }
   If A_GuiControlEvent = RightCLick
      gosub delprog


Return
;##########################################################################################
read:
IniRead,exelist,%local_ini%,exelist,list
LV_Delete()
loop,parse,exelist,~,`r`n
{
   if not A_LoopField
   Continue
   OutFileName=
   lver=
   rver=
   rpath=
   rinfo=
   SplitPath, A_LoopField , OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
   if OutExtension=exe
      fileGetVersion,%OutNameNoExt%lv,%A_LoopField%
   else
   {
      FileGetTime,%OutNameNoExt%lv,%A_LoopField%,M
      stringleft,%OutNameNoExt%lv,%OutNameNoExt%lv,8
   }
   FileGetSize,%OutNameNoExt%sz,%A_LoopField%,K
   lver:=%OutNameNoExt%lv  ;local version
   IniRead,%OutNameNoExt%rv,%local_ini%,%OutNameNoExt%,version ;remote version
   IniRead,%OutNameNoExt%p,%local_ini%,%OutNameNoExt%,path ;remotepath
   IniRead,%OutNameNoExt%info,%local_ini%,%OutNameNoExt%,vinfo ;info on update
   if %OutNameNoExt%p != Error
   rpath:=%OutNameNoExt%p
   if %OutNameNoExt%rv != Error
   rver:=%OutNameNoExt%rv
   if %OutNameNoExt%info != Error
   rinfo:=%OutNameNoExt%info
   if rver < %lver%
   LV_Add("check", OutFileName , lver, rver , rpath , A_LoopField , OutNameNoExt ,rinfo )
   else
   LV_Add(" ", OutFileName , lver, rver , rpath , A_LoopField , OutNameNoExt ,rinfo )
}
GuiControl, Choose, Tabz, 1
LV_ModifyCol(1,130)
LV_ModifyCol(2,100)
LV_ModifyCol(3,100)
LV_ModifyCol(4,100)
LV_ModifyCol(5)
LV_ModifyCol(6)
Return
Return
Return

/*
http://msdn.microsoft.com/library/en-us/wininet/wininet/ftp_sessions.asp
http://msdn.microsoft.com/library/en-us/wininet/wininet/internetopen.asp
http://msdn.microsoft.com/library/en-us/wininet/wininet/internetconnect.asp
*/

FtpCreateDirectory(DirName) {
global ic_hInternet
r := DllCall("wininet\FtpCreateDirectoryA", "uint", ic_hInternet, "str", DirName)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}

FtpRemoveDirectory(DirName) {
global ic_hInternet
r := DllCall("wininet\FtpRemoveDirectoryA", "uint", ic_hInternet, "str", DirName)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}

FtpSetCurrentDirectory(DirName) {
global ic_hInternet
r := DllCall("wininet\FtpSetCurrentDirectoryA", "uint", ic_hInternet, "str", DirName)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}

FtpPutFile(LocalFile, NewremoteFile="", Flags=0) {
;Flags:
;FTP_TRANSFER_TYPE_UNKNOWN = 0 (Defaults to FTP_TRANSFER_TYPE_BINARY)
;FTP_TRANSFER_TYPE_ASCII = 1
;FTP_TRANSFER_TYPE_BINARY = 2
If NewremoteFile=
NewremoteFile := LocalFile
global ic_hInternet
r := DllCall("wininet\FtpPutFileA"
, "uint", ic_hInternet
, "str", LocalFile
, "str", NewremoteFile
, "uint", Flags
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}

FtpGetFile(remoteFile, NewFile="", Flags=0) {
;Flags:
;FTP_TRANSFER_TYPE_UNKNOWN = 0 (Defaults to FTP_TRANSFER_TYPE_BINARY)
;FTP_TRANSFER_TYPE_ASCII = 1
;FTP_TRANSFER_TYPE_BINARY = 2
If NewFile=
NewFile := remoteFile
global ic_hInternet
r := DllCall("wininet\FtpGetFileA"
, "uint", ic_hInternet
, "str", remoteFile
, "str", NewFile
, "int", 0 ;1= do not overwrite existing files
, "uint", 0 ;dwFlagsAndAttributes
, "uint", Flags
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}

FtpGetFileSize(FileName, Flags=0) {
;Flags:
;FTP_TRANSFER_TYPE_UNKNOWN = 0 (Defaults to FTP_TRANSFER_TYPE_BINARY)
;FTP_TRANSFER_TYPE_ASCII = 1
;FTP_TRANSFER_TYPE_BINARY = 2
global ic_hInternet
fof_hInternet := DllCall("wininet\FtpOpenFileA"
, "uint", ic_hInternet
, "str", FileName
, "uint", 0x80000000 ;dwAccess: GENERIC_READ
, "uint", Flags
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or fof_hInternet = 0)
return -1

FileSize := DllCall("wininet\FtpGetFileSize", "uint", fof_hInternet, "uint", 0)
DllCall("wininet\InternetCloseHandle",  "UInt", fof_hInternet)
return, FileSize
}


FtpDeleteFile(FileName) {
global ic_hInternet
r :=  DllCall("wininet\FtpDeleteFileA", "uint", ic_hInternet, "str", FileName)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}

FtpRenameFile(Existing, New) {
global ic_hInternet
r := DllCall("wininet\FtpRenameFileA", "uint", ic_hInternet, "str", Existing, "str", New)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}

FtpOpen(Server, Port=21, Username=0, Password=0 ,Proxy="", ProxyBypass="") {
IfEqual, Username, 0, SetEnv, Username, anonymous
IfEqual, Password, 0, SetEnv, Password, anonymous

If (Proxy != "")
AccessType=3
Else
AccessType=1
;#define INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
;#define INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
;#define INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
;#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS

global ic_hInternet, io_hInternet, hModule
hModule := DllCall("LoadLibrary", "str", "wininet.dll")

io_hInternet := DllCall("wininet\InternetOpenA"
, "str", A_ScriptName ;lpszAgent
, "UInt", AccessType
, "str", Proxy
, "str", ProxyBypass
, "UInt", 0) ;dwFlags

If (ErrorLevel != 0 or io_hInternet = 0) {
FtpClose()
return 0
}

ic_hInternet := DllCall("wininet\InternetConnectA"
, "uint", io_hInternet
, "str", Server
, "uint", Port
, "str", Username
, "str", Password
, "uint" , 1 ;dwService (INTERNET_SERVICE_FTP = 1)
, "uint", 0 ;dwFlags
, "uint", 0) ;dwContext

If (ErrorLevel != 0 or ic_hInternet = 0)
return 0
else
return 1
}

FtpClose() {
global ic_hInternet, io_hInternet, hModule
DllCall("wininet\InternetCloseHandle",  "UInt", ic_hInternet)
DllCall("wininet\InternetCloseHandle",  "UInt", io_hInternet)
DllCall("FreeLibrary", "UInt", hModule)
}Return


I dont think it can get simpler.....
Thanks to Olfen and his Ftp Dll calls.

And the UPDATER.EXE code which doesnt use FTP and stays totally secure and does all the checking for Newer versions and Replaces the old ones.

Code:
SetWorkingDir %A_ScriptDir%
#NoEnv
#SingleInstance Force
SendMode Input
myserver=http://www.whatever.com   ;put your server url here

ifexist,%A_ScriptDir%\update.ini
FileDelete,%A_ScriptDir%\update.ini

UrlDownloadToFile,%myserver%/update.txt,%A_ScriptDir%\update.ini
_ini=%A_ScriptDir%\update.ini

fileread,files,%A_Scriptdir%\files.txt
   if ErrorLevel
      Exitapp
vinfo1= ### You Can Simply Check any filename to force a download: ###`n=================================================================`n

;##########################################################################################

Gui, Font, s9
   Gui, Add, ListView,x14 y12 w415 h150 vlist3 BackgRoundFFFFF9 AltSubmit grid glistboxclick Checked ,FileName|Local Version|Updated Version|Remote Path|shortname
   Gui, Add, Button,xp y+5 w100 r1 gstart ,Continue
   Gui, Add, Edit,T vvinfo x14 y+5 w415 h150 BackgRoundFFFFF9,%vinfo%
   Gui,Add,StatusBar,,
Gui,Show, AutoFit

;##########################################################################################
loop,parse,files,`n,`n`r
   {
   if not A_LoopField
      continue
   stringtrimright,trimmed,A_LoopField,4   
   IfNotExist,%A_ScriptDir%\%A_LoopField%
      {
      UrlDownloadToFile,%myserver%/%A_LoopField%,%A_ScriptDir%\%A_LoopField%
      updates++
      }
   iniread,%trimmed%ver1    ,%_ini%,%trimmed%,version,0.0.0.0
   iniread,%trimmed%location,%_ini%,%trimmed%,location,/
   iniread,%trimmed%vinfo   ,%_ini%,%trimmed%,vinfo,none

   fileGetVersion,%trimmed%ver ,%A_ScriptDir%\%A_LoopField%
   if not %trimmed%ver
      {
      fileGetTime,%trimmed%ver ,%A_ScriptDir%\%A_LoopField%,m
      stringtrimright,%trimmed%ver,%trimmed%ver,6
      }
   stringreplace,%trimmed%vinfo,%trimmed%vinfo,~,`n,all
   mess:=%trimmed%vinfo
   trimmedver1:=%trimmed%ver1
   trimmedver:=%trimmed%ver
   if trimmedver = %trimmedver1%
      %trimmed%mess=No Updates for %trimmed%`nLast Update was:`n %mess%`n
   else
      %trimmed%mess=1 Update for %trimmed%:`n%mess%`n
   
   if trimmedver = %trimmedver1%
      LV_Add(" ", A_LoopField , %trimmed%ver, %trimmed%ver1,%trimmed%location,trimmed)
   else
      LV_Add("check", A_LoopField , %trimmed%ver, %trimmed%ver1,%trimmed%location,trimmed)
   stringreplace,vinfo,%trimmed%vinfo,~,`n,all
   if vinfo
      vinfo1.=A_LoopField "`n" vinfo "`n=================================================================`n"
   }

GuiControl,,vinfo,%vinfo1%
LV_ModifyCol(" ",100)
LV_ModifyCol(4,100)
LV_ModifyCol(5,0)
LV_ModifyCol(1)

if LV_GetNext("","Checked")
      {
         settimer,start,-20000
          SB_SetText( "Wait 20Sec or Click Continue to Update Immediately" )
      }
if not LV_GetNext("","Checked")
      {
            SB_SetText( "Nothing to Update, Close whenever you like" )
      }
return
;##########################################################################################
start:
checkedrecord:=LV_GetNext("","Checked")
Loop % LV_GetCount()
{   
   if A_index <> %checkedrecord%
   continue
   loop 5
   c%A_Index%=
   checkedrecord:=LV_GetNext(checkedrecord,"Checked")
         LV_GetText(c1, A_Index,1)
         LV_GetText(c2, A_Index,2)
         LV_GetText(c3, A_Index,3)
         LV_GetText(c4, A_Index,4)
         localFile=%c1%
         LV_Modify(A_Index,"-Check")
         if c4=/
            c4=
         if c4 
            {
            stringleft,sl,c4,1   ;checking for / on both ends of string....
            stringright,sr,c4,1
            if sl=/   
            stringtrimleft,c4,c4,1
            if sr=/   
            stringtrimright,c4,c4,1
            remoteFile=%c4%/%c1%
            }
         else
            remoteFile=%c1%
   IfExist,%A_ScriptDir%\Updater.src
   FileDelete,%A_ScriptDir%\Updater.src   
    if c1 !=Updater.exe
    {
   FileDelete,%A_ScriptDir%\%c1%.bak
   filemove,%A_ScriptDir%\%c1%,%A_ScriptDir%\%c1%.bak
   if errorlevel
   continue
   }
    SB_SetText( "Downloading file " remoteFile )
    if c1 =Updater.exe
    UrlDownloadToFile,%myserver%/%remoteFile%,%A_ScriptDir%\Updater.src
    else
   UrlDownloadToFile,%myserver%/%remoteFile%,%A_ScriptDir%\%c1%
   updates++
   }
    Gui, submit,Nohide
   if not LV_GetNext("","Checked")
   {
    SB_SetText( "CLOSING UPDATER in 5" )
    sleep 1000
    SB_SetText( "CLOSING UPDATER in 4" )
    sleep 1000
    SB_SetText( "CLOSING UPDATER in 3" )
    sleep 1000
    SB_SetText( "CLOSING UPDATER in 2" )
    sleep 1000
    SB_SetText( "CLOSING UPDATER in 1" )
    sleep 1000
   }
Return
;##########################################################################################
return

exitapp

end:
if updates
MsgBox,0,Ver %Updaterver%,%updates% Updates`nyou are now up to date,3
FileDelete,%A_ScriptDir%\update.ini
exitapp

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GuiClose:
if updates
MsgBox,0,Ver %Updaterver%,%updates% Updates`nyou are now up to date,3
FileDelete,%A_ScriptDir%\update.ini
Exitapp
Return
;##########################################################################################
ListBoxClick:
            loop 6
            c%A_Index%=
         FocusedRowNumber := LV_GetNext(0, "F")  ; Find the Focused row.
                  If not FocusedRowNumber  ; No row is Focused.
               Return
         LV_GetText(c5, FocusedRowNumber,5)
;         GuiControl, Choose, Tabz, 2
         vinfo:=%c5%vinfo
         if vinfo=ERROR
         {
         GuiControl,,vinfo,
         Return
         }
         stringreplace,vinfo,vinfo,~,`n,all
         GuiControl,,vinfo,%vinfo%


Return
;##########################################################################################

ImageAll From files.txt which holds nothing more than filenames eg. Updater.exe


Last edited by Trubbleguy on February 19th, 2009, 8:04 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 5th, 2009, 12:12 am 
Offline

Joined: January 20th, 2007, 1:29 pm
Posts: 96
Location: Melbourne
the code i use to update some of my programs for you to modify
Code:
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
FileDelete,%A_ScriptDir%\update.ini

UrlDownloadToFile,http://www.trubbleguy.com/update.txt,%A_ScriptDir%\update.ini
_ini=%A_ScriptDir%\update.ini

start:
IniRead,lastnewfrontendver1,%_ini%,newfrontend,version
StringReplace, lastnewfrontendver, lastnewfrontendver1,.,,All
IniRead,nfevinfo,%_ini%,newfrontend,vinfo,none
stringreplace,nfevinfo,nfevinfo,~,`n,all

IniRead,lastUpdaterver1,%_ini%,updater,version
StringReplace, lastUpdaterver, lastUpdaterver1,.,,All
IniRead,updvinfo,%_ini%,updater,vinfo,none
stringreplace,updvinfo,updvinfo,~,`n,all

IniRead,lastbookcreatorver1,%_ini%,bookcreator,version
StringReplace, lastbookcreatorver, lastbookcreatorver1,.,,All
IniRead,bcvinfo,%_ini%,bookcreator,vinfo,none
stringreplace,bcvinfo,bcvinfo,~,`n,all

fileGetVersion,newfrontendver1,%A_ScriptDir%\NewFrontend.exe
StringReplace, newfrontendver, newfrontendver1,.,,All

fileGetVersion,Updaterver1,%A_ScriptDir%\Updater.exe
StringReplace, Updaterver, Updaterver1,.,,All

fileGetVersion,bookcreatorver1,%A_ScriptDir%\bookcreator.exe
StringReplace, bookcreatorver, bookcreatorver1,.,,All

if newfrontendver1 = %lastnewfrontendver1%
femess=No Updates for NewFrontend`nLast Update was:`n%nfevinfo%`n
else
femess=1 Update for NewFrontend`nThis Update is:`n%nfevinfo%`n

if Updaterver1 = %lastUpdaterver1%
udmess=No Updates for Updater`nLast Update was:`n%updvinfo%`n
else
udmess=1 Update for Updater`nThis Update is:`n%updvinfo%`n

if bookcreatorver1=%lastbookcreatorver1%
bcmess=No Updates for Bookcreator`nLast Update was:`n%bcinfo%`n
else
bcmess=1 Update for Bookcreator`nThis Update is:`n%bcvinfo%`n

MsgBox,0,Ver %Updaterver1%,%femess%`n%udmess%`n%bcmess%,30

if bookcreatorver < %lastbookcreatorver%
{
UrlDownloadToFile,http://www.trubbleguy.com/bookcreator.exe,%A_ScriptDir%\bookcreator.src
FileMove, %A_ScriptDir%\bookcreator.exe,%A_ScriptDir%\bookcreator.exe.bak,1
FileMove, %A_ScriptDir%\bookcreator.src,%A_ScriptDir%\bookcreator.exe,1
updates++
}

if newfrontendver < %lastnewfrontendver%
{
Process,Exist,NewFrontend.exe
If Errorlevel
{
WinActivate,Karaoke Search   
Send !q
MsgBox,0,Ver %Updaterver1%,NewFrontend still Active`,Automatically Closing it,4
sleep 4000
}
UrlDownloadToFile,http://www.trubbleguy.com/NewFrontend.exe,%A_ScriptDir%\NewFrontend.src
FileMove, %A_ScriptDir%\NewFrontend.exe,%A_ScriptDir%\NewFrontend.exe.bak,1
FileMove, %A_ScriptDir%\NewFrontend.src,%A_ScriptDir%\NewFrontend.exe,1
updates++
}

if Updaterver < %lastUpdaterver%
{
IfExist,%A_ScriptDir%\Updater.src
FileDelete,%A_ScriptDir%\Updater.src   
UrlDownloadToFile,http://www.trubbleguy.com/Updater.exe,%A_ScriptDir%\Updater.src
updates++
Run,%A_ScriptDir%\NewFrontend.exe

}
end:
if updates
MsgBox,0,Ver %Updaterver1%,%updates% Updates`nyou are now up to date`n You can now run NewFrontend`n%Updaterver%,3
else
MsgBox,0,Ver %Updaterver1%,no new updates,3
FileDelete,%A_ScriptDir%\update.ini
exitapp


_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Updater.exe added
PostPosted: February 19th, 2009, 7:40 am 
Offline

Joined: January 20th, 2007, 1:29 pm
Posts: 96
Location: Melbourne
Added Updater.exe Code which doesnt use FTP to update your software online.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 7:25 pm 
Offline

Joined: February 20th, 2007, 1:37 pm
Posts: 198
Location: D.C.
Sweet! I'll take a look at this one. Love your sig, btw!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 9:45 pm 
You can ftp with dll calls? I've been using the run, ftp.exe method. Is there any documentation on how to get this working?
Oh and nice program by the way. I was looking of a way to do this but without a gui.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group