AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Automatic Updating

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jonny



Joined: 13 Nov 2004
Posts: 2951
Location: Minnesota

PostPosted: Sat Dec 11, 2004 8:13 pm    Post subject: Automatic Updating Reply with quote

Mad What happen? Somebody set us up the error.

This is my code for automatic retrieval of the latest version of AHK (I couldn't think of a way for it to automatically check if anything's changed)

It downloads an .exe, but it encounters an error when run:
Message Box wrote:
C:\AUTOHO~1.EXE
The NTVDM CPU has encountered an illegal instruction.
CS:0535 IP:fff5 OP:ff f8 ff fa ff Choose 'Close' to terminate the application.
Close/Ignore


Code:
U_TmpHtm = C:\ahk.html
U_TmpExe = C:\AutoHotkey.exe
URLDownloadToFile,http://www.autohotkey.com/download/,%U_TmpHtm%
Loop,Read,%U_TmpHtm%
 {
  ; The error might be here, in the URL, but I doubt it.
  IfInString,A_LoopReadLine,http://home.tampabay.rr.com/kodi/ahk/
   {
    U_Line = %A_LoopReadLine%
    U_LineNumber = %A_Index%
    Break
   }
 }
FileDelete,%U_TmpHtm%
If U_Line =
 {
  MsgBox,An error has occured: The specified link no longer exists.`nAutoUpdate will now close.
  ExitApp
 }

; The error's more likely somewhere in here.
; Any clues to where it goes wrong?
StringGetPos,U_URLBegin,U_Line,http://home.tampabay.rr.com/kodi/ahk/
U_URLBegin += 1
StringGetPos,U_URLEnd,U_Line,exe
U_URLEnd += 2
U_Count = %U_URLEnd%
U_Count -= %U_URLBegin%
StringMid,U_URL,U_Line,%U_URLBegin%,%U_Count%
URLDownloadToFile,%U_URL%,%U_TmpExe%
Run,%U_TmpExe%
Return
Back to top
View user's profile Send private message
Simpleton



Joined: 02 Nov 2004
Posts: 14

PostPosted: Sat Dec 11, 2004 8:51 pm    Post subject: Reply with quote

I copied your script and added a
MsgBox, %U_URL% - %U_TmpExe%
before the Run command.
It revealed that it was downloading AutoHotKey1024.e instead of AutoHotKey1024.exe which is why it isn't working.
I simply changed the line:
U_URLEnd += 2
to
U_URLEnd += 4
and it appears to be working. My internet connections sucks so it will be awhile before I can check for sure (it's still dl it) though.
Back to top
View user's profile Send private message
jonny



Joined: 13 Nov 2004
Posts: 2951
Location: Minnesota

PostPosted: Sat Dec 11, 2004 10:55 pm    Post subject: Reply with quote

Yes, it works now. Now I just need a way to see if there's any way to check for installer changes and version updates, and also a way to automatically delete the installer when it's done running.
Back to top
View user's profile Send private message
Jon



Joined: 28 Apr 2004
Posts: 349

PostPosted: Sat Dec 11, 2004 11:46 pm    Post subject: Reply with quote

Quote:
Yes, it works now. Now I just need a way to see if there's any way to check for installer changes and version updates, and also a way to automatically delete the installer when it's done running.


This should work-

Code:
U_TmpHtm = C:\ahk.html
U_TmpExe = C:\AutoHotkey.exe
URLDownloadToFile,http://www.autohotkey.com/download/,%U_TmpHtm%
Loop,Read,%U_TmpHtm%
 {

  IfInString,A_LoopReadLine,http://home.tampabay.rr.com/kodi/ahk/
   {
    U_Line = %A_LoopReadLine%
    U_LineNumber = %A_Index%
    Break
   }
 }
FileDelete,%U_TmpHtm%
If U_Line =
 {
  MsgBox,An error has occured: The specified link no longer exists.`nAutoUpdate will now close.
  ExitApp
 }


StringGetPos,U_URLBegin,U_Line,http://home.tampabay.rr.com/kodi/ahk/

U_URLBegin += 1
StringGetPos,U_URLEnd,U_Line,exe
U_URLEnd += 4
U_Count = %U_URLEnd%
U_Count -= %U_URLBegin%
StringMid,U_URL,U_Line,%U_URLBegin%,%U_Count%

StringMid, version1, U_URL, 51, 4, L

RegRead, version2, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AutoHotkey, DisplayName

StringRight, version2, version2, 6

StringReplace, version2, version2,.,,All

if version1 <> %version2%
{
URLDownloadToFile,%U_URL%,%U_TmpExe%
Run,%U_TmpExe%

winwait, ahk_class #32770
winwaitclose, ahk_class #32770
filedelete, %U_TmpExe%
}
else
{
msgbox, you have the latest version of Autohotkey
}


Return


I havn't tested it with older versions of autohotkey though.
Back to top
View user's profile Send private message Send e-mail
Simpleton



Joined: 02 Nov 2004
Posts: 14

PostPosted: Sun Dec 12, 2004 12:58 am    Post subject: Reply with quote

one slight problem is that AHK gets updated often without being marked on the front page. There is no way to know if it's been updated besides downloading the exe and comparing it the previous one.

Maybe Chris could make a special page for this, like www.autohotkey.com/autoupdate/ and just have like:
<full version including all minor updates>
<address of zipped copy of latest>

then the autoupdater could determine if it needs updating, dl the update, and install it itself, without having to bother the user with the installler exe. Guess youd need to include a free command line unzip program but thats not a big deal.
Back to top
View user's profile Send private message
jonny



Joined: 13 Nov 2004
Posts: 2951
Location: Minnesota

PostPosted: Sun Dec 12, 2004 1:27 am    Post subject: Reply with quote

Maybe we could just start a simple notation method, starting with the current state of the installer. Probably just add one for each change to it, like say today the version is "1", but tomorrow Chris makes a small bug fix so it becomes "2". The page wouldn't really need to be readable by humans, so it could just be
Code:
<HTML><BODY>
1
http://home.tampabay.rr.com/kodi/ahk/AutoHotkey1024.exe
</BODY></HTML>


and it'd just have to read line 2 for any changes, and line 3 for the url to read if there have been. To make it simpler, it could also be 001 or 0001.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Sun Dec 12, 2004 2:37 am    Post subject: Reply with quote

That's a nice idea. A few thoughts:

1) It's another page that would need to be updated with every update. I know it's a small thing, but all these little chores add up.

2) As an alternative, you could click the "watch this topic for replies" link under the "Pre-1.0.xx" topic to be notified via e-mail whenever an interim release is done.

3) Would you really want to install every update before even knowing what's been changed in it?

I do like the general idea, so in any case I'll add to the to-do list: "A menu item in a script's main window to check whether you're running the latest version of the program, and if not, perhaps offer the option to automatically download and install the latest."

Thanks.
Back to top
View user's profile Send private message Send e-mail
Simpleton



Joined: 02 Nov 2004
Posts: 14

PostPosted: Sun Dec 12, 2004 3:07 am    Post subject: Reply with quote

Main reason some type of autoupdate would be really nice would be for me is that my internet connection is fairly (ok, very very) slow, but I like to stay current and often the latest fix will be something I'd been waiting for. I find myself downloading the entire installer many times a week and reinstalling all of AHK, which includes resetting my fav editor as the default editor for ahk scripts, because the ahk installer resets it to notepad.

maybe just releasing a zipped version of it would be enough. If my computer autoupdated ahk every night while I sleep that'd be good enough for me.
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Sun Dec 12, 2004 9:03 am    Post subject: Reply with quote

Well, a sequenze number/char (0-9 Aa-Zz) would be a quick workaround

good: AutoHotkey1000.exe
better: AutoHotkey1000.a.exe

This way its possible to use URLDownloadToFile and its Errorlevel to check if a succesfull download/match could be made.

I've had a Google session about a command line [CMD] download tool which gets any info about the file (name/size/date) --> before a download will be started. "Unfortunately" it was a Shareware and I ignored it. Maybe AHK will provide an URLGetFileInfo command in the future Wink

-----

Quote:
because the ahk installer resets it to notepad


Yep, that's quite annoying Rolling Eyes
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Sun Dec 12, 2004 2:40 pm    Post subject: Reply with quote

Simpleton wrote:
maybe just releasing a zipped version of it would be enough. If my computer autoupdated ahk every night while I sleep that'd be good enough for me.
Thanks, I'll make sure a ZIP version is on the to-do list.

Quote:
Maybe AHK will provide an URLGetFileInfo command in the future.
Yes, that's planned. Checking the size of the download is probably enough to detect changes, since only very rarely would it be the same after an update.

Quote:
because the ahk installer resets it to notepad
Yep, that's quite annoying
Thanks. I'm going to change it so that the current editor settings are retained by default, perhaps with a checkbox to change it back to Notepad.

Feedback like this is welcome; if anything else annoys you about the program, please share it.
Back to top
View user's profile Send private message Send e-mail
BoBo
Guest





PostPosted: Sun Dec 12, 2004 10:42 pm    Post subject: Reply with quote

A "workaround" ... Wink

Quote:
Get File Size - Lets you find out the size of a file before downloading it.

Version: 2.0.4
Last Updated: 06/01/2004
Size: 556 KB
File type: Executable
Install & Uninstall Included
Runs on: Windows 98/ME/NT/2000/XP
License: Free

[Download]


Cool
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group