#1
|
|||
|
|||
Dynamic HTA
Hello guys, I'm am trying to figure out how to create an HTA from within vbscript (like the ie example) then take input from that and use it to run commands with crt.screen.send. I know it can be dome because some guys at IT have done it, the problem is they built the scripts with object oriented programming. I am not able to trace through all the scripts to determine how it's done. Guys at IT were no help. Basically it want each script to have the HTA info then pass it on to the main script to build the UI. Anyone done that here? I tried to search but "HTA" is too short. Thanks!
|
#2
|
|||
|
|||
Hi krillik,
We don't have any experience with building HTA, but there might be others who have (your IT team, for example ![]() You can use Google technology to search the forums for terms that are smaller than the forum search will allow. For example, site:forums.vandyke.com HTA |
#3
|
|||
|
|||
rtb, I appreciate your reply. I tried to google so many things on the internet in general and I could not find anything the way I wanted to do it. So I got the bright idea to google a certain piece of the code, the mshta process that runs htas.
I found this link http://gallery.technet.microsoft.com...cript-36122f57 and it does EXACTLY what I want. I think its a better way to do things than to use the IE object hack as it doesnt run into the security restrictions. The code needs to be modified to work with SecureCRT but I was able to do that fairly quickly(wsh.sleep <to> crt.sleep, etc.). I hope that helps people who have also been trying to do that! |
#4
|
|||
|
|||
Hi krillik,
I am glad to hear that you found a solution. Thanks for posting a reference. |
#5
|
|||
|
|||
Quote:
My latest update to SecureCRT does not work at all with the latest IE... |
#6
|
|||
|
|||
Code
As requested here is the code I modified, I am no expert but it does not seem to thrown any errors or anything when I run it.
Code:
sMessage = "<font color=red><b>This is your important message</b></font>" sControl = "<input type=button id=Btn1 value=OK onclick='done.value=""clicked""'>" sHTMLCode = sMessage & "<hr>" & sControl ' with HTABox("lightgrey", 125, 300, 400, 500) .document.title = "My Message Box" .msg.innerHTML = sHTMLCode Timeout = 3000 ' milliseconds do until .done.value = "clicked" or (n > TimeOut): crt.sleep 50 : n=n+50 : loop if .done.value = "clicked" then crt.Dialog.Messagebox("User pressed button") else crt.Dialog.Messagebox("Timed out") end if .done.value = true .close end with ' ' Author Tom Lavedas, June 2010 Function HTABox(sBgColor, h, w, l, t) Dim IE, HTA randomize : nRnd = Int(1000000 * rnd) sCmd = "mshta.exe ""javascript:{new " _ & "ActiveXObject(""InternetExplorer.Application"")" _ & ".PutProperty('" & nRnd & "',window);" _ & "window.resizeTo(" & w & "," & h & ");" _ & "window.moveTo(" & l & "," & t & ")}""" ' with CreateObject("WScript.Shell") .Run sCmd, 1, False do until .AppActivate("javascript:{new ") : crt.sleep 10 : loop end with ' WSHShell ' For Each IE In CreateObject("Shell.Application").windows If IsObject(IE.GetProperty(nRnd)) Then set HTABox = IE.GetProperty(nRnd) IE.Quit HTABox.document.title = "HTABox" HTABox.document.write _ "<HTA:Application contextMenu=no border=thin " _ & "minimizebutton=no maximizebutton=no sysmenu=yes />" _ & "<body scroll=no style='background-color:" _ & sBgColor & ";font:normal 10pt Arial;" _ & "border-Style:outset;border-Width:3px'" _ & "onbeforeunload='vbscript:if not done.value then " _ & "window.event.cancelBubble=true:" _ & "window.event.returnValue=false:" _ & "done.value=true:end if'>" _ & "<input type=hidden id=done value=false>" _ & "<center><span id=msg> </span><center></body>" Exit Function End If Next ' ' I can't imagine how this line can be reached, but just in case MsgBox "HTA window not found." End Function Last edited by krillik; 05-08-2014 at 01:03 PM. Reason: Made a mistake in code, removed it |
![]() |
Tags |
dialog , hta |
Thread Tools | |
Display Modes | Rate This Thread |
|
|