Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 12 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
What you are trying to do cannot be made to work. HTAs are only single threaded. You cannot successfully update the screen from inside of an event no matter how you trigger the event. Using a timer only delays the problem.
I thought I would take a bit of time to clarify what I mean by your project being near to impossible.
Every few months someone asks pretty much the same questions: How can I get my screen to update with new output as it is available?
I know you have seen what you may believe to be this kind of thing when browsing the web. The big issues is that from a web site this can be made possible through the use of
When the scan is complete the files will be displayed in a nice table with a clickable name that will launch the file in the default display program.
Very nice script Thank you for this great work and spending time to help us !
when i test this code under windows Seven: So it display me a name of the file but not clickbale and don't launch the file in the default display Program i don't know why ??
so i modified a little this script to try to display images as thumbnails and clickable so as a result it show me some images and other no ??? I wonder Why ? and this due of what exactly ?? Code programming or cache images i don't know ? here is my modification :
Const START_FOLDER = "."
Const FILE_EXT = "jpg,gif,bmp,psd,tif"
' set up extension lists object for easy comparisons.
Set lstExt = CreateObject("System.Collections.ArrayList")
For Each e In Split(FILE_EXT,",")
lstExt.Add LCase(e)
Next
' NOw get an dsiplay an IE browser.
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "about:blank"
ie.ToolBar = 0
ie.StatusBar = 0
ie.Visible = True
'
Dim pbar
Set doc = ie.Document.DocumentElement.LastChild
Set wrapper = ie.Document.createElement("div")
wrapper.id = "wrapper"
wrapper.style.backgroundcolor = "lightblue"
wrapper.style.width = ie.width - 50
doc.appendChild wrapper
Set pbar = ie.Document.createElement("div")
pbar.id = "pbar"
pbar.style.backgroundcolor = "blue"
wrapper.appendChild pbar
Set label = ie.Document.createElement("label")
label.id = "label"
label.style.backgroundcolor = "lightgreen"
label.style.width = 400
doc.appendChild label
'ie.Document.writeln "<body><div id='wrapper' style='background-color:lightblue;'><div id='pbar' style='background-color: blue; width: 1; height: 20;'></div></div><body>"
Set table = ie.Document.createElement("table")
Set oTHead = table.createTHead()
oTHead.setAttribute "bgColor","lightskyblue"
heading = Array( "File Name","Size","Type","Last Modified")
Set row = oTHead.insertRow(-1)
For i = 0 to UBound(heading)
Set oCell = row.insertCell(-1)
oCell.align = "center"
oCell.style.fontWeight = "bold"
oCell.innerHTML = heading(i)
Next
Set tbody = table.tbodies(0)
Set oTFoot = table.createTFoot()
Set caption = table.createCaption()
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(START_FOLDER)
count=0
counted = 0
found = 0
CountFiles fld
ListDirectory fld
doc.appendChild table
Function ListDirectory(f)
For Each fi In f.Files
cheminFic = f & "" & fi.name
counted = counted + 1
If lstExt.Contains(LCase(fso.GetExtensionName(fi.Name))) Then
found = found + 1
DisplayFIle fi,cheminFic
End If
Next
For Each fldr In f.SubFolders
ListDirectory fldr
Next
End Function
Function CountFiles(f)
count = count + f.Files.Count
For Each fldr In f.SubFolders
CountFiles fldr
Next
End Function
Function DisplayFile( file,cheminFic )
Set row = tbody.insertRow(-1)
AddCell row, "<center><a target=_Blank href='"& cheminFic &"'>"&_
"<img src= '"& cheminFic &"' width=80><BR>"&_
"<br><a href='" & file.ParentFolder & "'>The Location of " & file.Name & "</a>"
AddCell row, "<center>"& FormatNumber((file.Size/1024),2) + " Kb </center>"
AddCell row, "<center>"& file.Type &"</center>"
AddCell row, "<center>"& file.DateLastModified &"</center>"
Set pbar = ie.Document.getElementByID("pbar")
pbar.style.width = Replace(wrapper.style.width,"px","") * (counted / count)
label.innerHTML = "Total Files:" & count & " Total Processed:" & counted & " Found:" & found
End Function
Function AddCell( row, text )
Set cell = row.insertCell(-1)
cell.align = "left"
cell.style.fontWeight = "bold"
cell.innerHTML = text
End Function
Sorry - I just noticed what I wrote in your quote.
Unfortuantely doing this with IE output is not 'clickable'. I thought I had removed that line.
I have another solution which is evented which I will try and package and post later.
The IE can be made to runscript however it will probably not work on most versions of IE on newer machines due to security restrictions. THis depends on how 'locked down' your installation is. IE is allowed to display graphics but it cannot launch external programs. This is why we use an HTA fo admin scripts. AN HTA is identical to IE exept that it is not sandboxed.
YOu aer trying to modify code using mostly obsolete methods of HTML. To manage the table you need to use teh 'style' property of the object to set the style values.
What the heck is 'chemFic'? It is not anything to so with this code. You cannot just take arbitrary code an paste it in somewhere.
I know all of this is very confusing. If you were to spend some time trying to learn how to script with DHTML it would be a powerful learning tool. The techniques I have posted here are advanced but are also fundamental to both Windows and to DHTML scripting.
Start by following the executon through. Try an understand why each subroutine has been separated out. Once you can follow the code you will begin to understand how a DHTML script works.
With IE automation string building - the way you are trying to do things - will not work correctly most of the time. Object creation and management is really the only viable method.
Displaying a functional 'ProgressBar' is not possible using string building techniques. The objects must exist and not be replaced. We need to update the objects dynamically or the code will freeze or abort.
The best way to do all of teh formatting is to use a style sheet. The style sheet can be external and added as a refereence or we can inject a style sheet as part of the document. Styles can be created dynamically just like other objects.
One other note - can you please attach your code as a file attachment like I did? It is nearly impossible to copy and paste a large block of code from these forum pages.
This topic is 12 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.