Check for latest version.

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Check for latest version.

26 Sep 2017, 09:23

Alrighty, I'm starting to see people using an outdated version of AHK, mainly for not using AHK in a long time and forgetting to update it.
So, I've got this little script that these exact users can use to update their version of AHK. Here it is:

Code: Select all

If (Update() > A_AHKVersion) {
	MsgBox, 0x2034
		, Update?
		, It seems that you are running an outdated version of AHK.`n
		. Would you like to update it now?
	If (MsgBoxRB("Yes") && (!A_IsAdmin)) {
		MsgBox, 0x2001
			, Portable install?
			, There seems to be a bit of a problem, you aren't an admin of the current system.`n
			. Would you like to install the portable download instead?
		If (MsgBoxRB("Ok"))
			Run % "https://autohotkey.com/download/ahk.zip"
	} Else If (MsgBoxRB("Yes")) && (A_IsAdmin)
		Run % "https://autohotkey.com/download/ahk-install.exe"
	Else If (MsgBoxRB("No"))
		ExitApp
}

Update() {
	whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	whr.Open("GET", "https://autohotkey.com/download/1.1/version.txt", true)
	whr.Send()
	whr.WaitForResponse()
	Return := whr.ResponseText
}

MsgBoxRB(Type) {
	IfMsgBox, %Type%
		Return True
	Else
		Return False
}
Might be redundant to use this since someone else might have already made this script, but if not, it's up for usage.
Last edited by Delta Pythagorean on 30 Sep 2017, 11:32, edited 1 time in total.

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Check for latest version.

29 Sep 2017, 05:10

tnx for sharing!
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: Check for latest version.

29 Sep 2017, 10:13

Error at line 3.

% sign missing at the end it says
Ruevil2
Posts: 173
Joined: 14 Jul 2014, 10:39

Re: Check for latest version.

29 Sep 2017, 11:18

fenchai wrote:Error at line 3.

% sign missing at the end it says
Then after you fix that it throws this syntax error due to a missing opening bracket...
Error at line 1.

Call to nonexistent function.
Then after you fix that it throws this error due to a missing parenthesis.
Error at line 6.

Missing ")"
Then it will actually work.




Working code:

Code: Select all

If (Update() > A_AHKVersion) {
	MsgBox, 0x2034
		, Update?
		, It seems that you are running an outdated version of AHK.`n
		. Would you like to update it now?
	If (MsgBoxRB("Yes") && (!A_IsAdmin)) {
		MsgBox, 0x2001
			, Portable install?
			, There seems to be a bit of a problem, you aren't an admin of the current system.`n
			. Would you like to install the portable download instead?
		If (MsgBoxRB("Ok"))
			Run % "https://autohotkey.com/download/ahk.zip"
	} Else If (MsgBoxRB("Yes")) && (A_IsAdmin)
		Run % "https://autohotkey.com/download/ahk-install.exe"
	Else If (MsgBoxRB("No"))
		ExitApp
}

Update() {
	whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	whr.Open("GET", "https://autohotkey.com/download/1.1/version.txt", true)
	whr.Send()
	whr.WaitForResponse()
	Return := whr.ResponseText
}

MsgBoxRB(Type) {
	IfMsgBox, %Type%
		Return True
	Else
		Return False
}
garry
Posts: 3760
Joined: 22 Dec 2013, 12:50

Re: Check for latest version.

29 Sep 2017, 15:26

example with activeX ( AHK-version & VLC-version)
EDIT : modified for IExplorer or Firefox

Code: Select all

;-------- https://autohotkey.com/boards/viewtopic.php?f=6&t=37526 ---
;- vlc-version & ahk-version
;--------------------------------------------------
Gui,4:Color, Black
Gui,4:Font,cYellow,FixedSys
ifnotexist,%a_programfiles%\Mozilla Firefox\firefox.exe
  xxa=Shell.Explorer                   ;- IExplorer
else
  xxa=Mozilla.Browser                  ;- firefox
xxc=VideoLAN.VLCPlugin.2               ;- vlc.exe

F1    :="https://autohotkey.com/download/1.1/version.txt"
vlcxx  =%A_programfiles%\VideoLAN\VLC\vlc.exe
ifexist,%vlcxx%
  Gui,4: Add, ActiveX, x1 y2  w0 h0  vVlcx,%xxc%
Gui,4: Add, ActiveX, x1 y35 w300 h30 vWbxx,%xxa%
ifexist,%vlcxx%
 dc:=vlcx.versionInfo()
;--- versionx ansi or unicode ---------
if (A_IsUnicode)
  codex := " Encoding is Unicode"
else
  codex := " Encoding is ANSI"
aa :=  ( InStr( (v:=A_AhkVersion), "1.1" ) ? "ahk_L " : "ahk_Basic " ) v  codex
Gui,4: add,text,x10 y5    ,Actual AHK-VERSION  =
Gui,4: add,text,x10 y75   ,Your AHK-version is = %aa%
Gui,4: add,text,x10 y100  ,Your VLC-version is = %dc%
WBxx.Navigate(F1)
Gui,4: Show,center h150
return
4GuiClose:
exitapp
Last edited by garry on 30 Sep 2017, 01:35, edited 1 time in total.
SpecialGuest
Posts: 26
Joined: 15 May 2016, 07:49

Re: Check for latest version.

29 Sep 2017, 19:41

I ended up using this as the other scripts seemed to fail for me :
Spoiler
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Check for latest version.

29 Sep 2017, 23:02

Sorry for making the script so crappy. I was using a crappy editor on a Mac, I just made it for shits and giggles and I just decided to make it. I'll edit the original script for usage. Sorry again guys and gals.

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

garry
Posts: 3760
Joined: 22 Dec 2013, 12:50

Re: Check for latest version.

30 Sep 2017, 01:38

sometimes I have problem with urldownloadtovar , then used wget.exe
modified script above to use with IExplorer or Mozilla Firefox
SpecialGuest
Posts: 26
Joined: 15 May 2016, 07:49

Re: Check for latest version.

30 Sep 2017, 07:20

Delta Pythagorean wrote:Sorry for making the script so crappy. I was using a crappy editor on a Mac, I just made it for shits and giggles and I just decided to make it. I'll edit the original script for usage. Sorry again guys and gals.
No need to apologize Delta - we're always appreciative of you sharing your creativity with us :ugeek:
We're just helping your innitiave a little :xmas: Thanks for sharing it
VazerOG
Posts: 1
Joined: 25 Feb 2021, 20:56

Re: Check for latest version.

25 Feb 2021, 21:03

This is an ancient forum. But it's the first one that comes up in Google. I'll post the code for checking for the latest version. It works great for me. Haven't been able to test to see if it will actually update AHK, but we'll see. I modified the code from above. It especially works for checking the version, which I was having issues with on my current version. The IF statement isn't able to test whether or not a string is less than another string. You have to convert it into a number first. Which is what the code above is.

Code: Select all


setTimer, checkUpdate, 21600000
		checkUpdate: 
			checkUpdate()

Update() {
		whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
		whr.Open("GET", "https://autohotkey.com/download/1.1/version.txt", true)
		whr.Send()
		whr.WaitForResponse()
		rawVersion := whr.ResponseText
		latestVersion := StrReplace(rawVersion,".")
		return latestVersion
	}

	currentVersion() {
		currentVersion := StrReplace(A_AhkVersion,".")
		Return currentVersion
	}

	checkUpdate() {
	If (Update() > currentVersion()) {
		MsgBox, 4, Update Available, A new update is available for AHK. `nUpdate Now?
		IfMsgBox, Yes
		{
			;MsgBox, % A_WorkingDir
			UrlDownloadToFile, https://autohotkey.com/download/ahk-install.exe, update.exe
	;		FileCreateDir, C:\temp\ahk
			Sleep 3000
			Run *RunAs update.exe
		}
		IfMsgBox, No
			{
			return
			}
		}
	}

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: dipahk, gwarble and 70 guests