rem
rem Sample Window Scripting Host Script 
rem that aims to rehack the cdrom key of a game
rem
dim aa

set WshShell = CreateObject("WScript.Shell")

base_x="9B1K"
base_y="9G"

for jj=1 to 36
  for kk = 1 to 36
    aa=base_y+chr(remap(jj))+chr(remap(kk))
    inputkey base_x, aa
  next
next

function remap(kk)
  if kk > 26 then
    remap=47+kk-26
  else
    remap=64+kk
  end if
end function

function inputkey(keyx, keyy)
WshShell.AppActivate "Diablo II - CD-key."
rem alt-n to select field "name"
WshShell.SendKeys "%N"
WshShell.SendKeys "man-wai chang"

WshShell.SendKeys "%N"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys "GT29"

WshShell.SendKeys "%N"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys "GD6R"

WshShell.SendKeys "%N"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys keyx

WshShell.SendKeys "%N"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys "{Tab}"
WshShell.Sendkeys keyy

rem Alt-O to click ok
WshShell.SendKeys "%O"
WScript.Sleep 200

* delay to allow time for install to check the key

rem if the key is invalid, a window named "Invalid Cd-key"
rem would have popped up. Press  to clean it out

WshShell.SendKeys " "
end function