$=SetOption("wow64alternateregview","on")
$reg = ReadValue("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion","DigitalProductId")
Dim $arrKey[]
$i=1
While ($i < LEN($reg))
ReDim Preserve $arrKey[Ubound($arrKey)+1]
$arrKey[Ubound($arrKey)] = Val("&"+SubStr($reg,$i,2))
$i=$i+2
Loop
? "Installed Key: "+ConvertToKey($arrKey)
Function ConvertToKey($Key)
;Check if OS is Windows 8
$isWin8 = ($Key[66] / 6) And 1
$Key[66] = ($Key[66] And &F7) Or (($isWin8 And 2) * 4)
$KeyOffset = 52
$i = 24
$Maps = "BCDFGHJKMPQRTVWXY2346789"
Do
$Current = 0
$j = 14
Do
$Current = $Current * 256
$Current = $Key[$j+$KeyOffset] + $Current
$Key[$j + $KeyOffset] = ($Current / 24)
$Current = $Current Mod 24
$j=$j-1
Until $j < 0
$i = $i-1
$KeyOutput = SubStr($Maps, $Current+1, 1) + $KeyOutput
$Last = $Current
Until $i < 0
$keypart1 = SubStr($KeyOutput, 2, $Last)
$insert = "N"
$KeyOutput = SubStr($KeyOutput, 2, LEN($KeyOutput))
$KeyOutput = Join(Split($KeyOutput, $keypart1),$keypart1+$insert)
If $Last = 0
$KeyOutput = $insert+$KeyOutput
EndIf
$ConvertToKey=SubStr($KeyOutput,1,5)+"-"+SubStr($KeyOutput,6,5)+"-"+SubStr($KeyOutput,11,5)+"-"+SubStr($KeyOutput,16,5)+"-"+SubStr($KeyOutput,21,5)
EndFunction