AutoHotkey Community

It is currently May 27th, 2012, 7:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Automatic Updating
PostPosted: December 11th, 2004, 9:13 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
:x 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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2004, 9:51 pm 
Offline

Joined: November 2nd, 2004, 5:06 pm
Posts: 14
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2004, 11:55 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2004, 12:46 am 
Offline

Joined: April 28th, 2004, 1:12 pm
Posts: 349
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2004, 1:58 am 
Offline

Joined: November 2nd, 2004, 5:06 pm
Posts: 14
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2004, 2:27 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2004, 3:37 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2004, 4:07 am 
Offline

Joined: November 2nd, 2004, 5:06 pm
Posts: 14
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2004, 10:03 am 
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 :roll:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2004, 3:40 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2004, 11:42 pm 
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]


8)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, just me and 74 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