Tuesday, September 6, 2011

STEP 002 web interface hello world

Now for the interface
open notepad

first we have to assume most objects in windows are accessible in 32 bits only
so we will make a script that restart himself in 32 bits if your windows is in 64 bits
for that we have to find if windows is 64 bits
we need a few windows objects for that
so we will create a filesystemobject to chek folders and if we are in syswow64 (the 32 bits wscript.exe that will run our script)

-------------------------- test3.vbs -----------------------
'=== object for files and filenames
Set objFSO    = CreateObject("Scripting.FileSystemObject")

'=== object to rerun the script in 32 bits
Set objshe    = CreateObject("WScript.Shell")


'=== actual drive, actual directory, and "\" we need it to rerun the script in 32 bits
thepath=WScript.ScriptFullName
p = instrRev(thepath,"\")
basedir  = left(thepath,p)
'=== script name to rerun it in 32 bits
filnam = right(thepath,len(thepath)-p)


'=== windows dir


WinDir = objfso.GetSpecialFolder(0)

'=== restart the script in 32 bits if we are on a 64 bits system
'=== (databases drivers issues)
a64 = windir & "\syswow64\wscript.exe"

if objFSO.fileEXISTS(a64) and instr(lcase(wscript.fullname),"syswow64")=0 then
   '=== 64 bits system
   a = """" & a64 & """ """ & basedir & filnam & """"
   objshe.Run a,0, false
   wscript.quit
end if

'=== create an internet explorer object to display stuff
set oIE = wscript.CreateObject("InternetExplorer.Application", "IE_")
oie.FullScreen = False

oIE.left=0 ' window position
oIE.top = 0 ' and other properties
oIE.height = 500
oIE.width = 500
oIE.menubar = 1 '=== no menu
oIE.toolbar = 1
oIE.statusbar = 1
oIE.RegisterAsDropTarget = True
oie.Navigate("about:blank")
oie.document.title = doctit
oiewid = oie.document.parentwindow.screen.width
oiehei = oie.document.parentwindow.screen.height
'=== we generate a size in % of the screen height and width for the internet explorer window
sizwidpercent = 100
sizheipercent = 95
loswid = 100-sizwidpercent
loshei = 100-sizheipercent
newwid = oiewid*sizwidpercent*.01
newhei = oiehei*sizheipercent*.01
oie.document.parentwindow.resizeto newwid,newhei
newx = oiewid * loswid * .01 /2
newy = oiehei * (loshei/2) * .01 /2
oie.document.parentwindow.moveto newx, newy
oIE.visible = 1 '=== visible on
oie.addressbar=false

'=== write a line in the internet explorer window, no html for now
oie.document.WriteLn("Hello World")


oie.document.WriteLn("<br><br>You can close internet explorer now, the program have ended")




'=== end of program
wscript.quit

'=== at the end of the program, we have the sub and functions

'=== if internet explorer is closed, we leave script

sub IE_onQuit()
   wscript.quit
end sub

------------------- end of .vbs --------------------

Now you might find this a little big just to display hello world
But it's a frame you can use for many purpose

Our purpose here is to learn how to program
So we needed a fast way to have an interface and use it to display our results
(input of results in a box, will come later)

For the near futur we will concentrate on programming nice code, with a nice structure
and have a few output to see if the code is working ;)






No comments:

Post a Comment