Advertisement
omegastripes

multiline_inputbox_via_hta.vbs

Jun 3rd, 2014
2,302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dim completed
  2.  
  3. msgbox inputboxml("Enter text:", "Multiline inputbox via HTA", "default" & vbcrlf & vbtab & "multiline" & vbcrlf & "text")
  4.  
  5. function inputboxml(prompt, title, defval)
  6.     set window = createwindow()
  7.     completed = 0
  8.     defval = replace(replace(replace(defval, "&", "&amp;"), "<", "&lt;"), ">", "&gt;")
  9.     with window
  10.         with .document
  11.             .title = title
  12.             .body.style.background = "buttonface"
  13.             .body.style.fontfamily = "consolas, courier new"
  14.             .body.style.fontsize = "8pt"
  15.             .body.innerhtml = "<div><center><nobr>" & prompt & "</nobr><br><br></center><textarea id='hta_textarea' style='font-family: consolas, courier new; width: 100%; height: 580px;'>" & defval & "</textarea><br><button id='hta_cancel' style='font-family: consolas, courier new; width: 85px; margin: 10px; padding: 3px; float: right;'>Cancel</button><button id='hta_ok' style='font-family: consolas, courier new; width: 85px; margin: 10px; padding: 3px; float: right;'>OK</button></div>"
  16.         end with
  17.         .resizeto 700, 700
  18.         .moveto 100, 100
  19.     end with
  20.     window.hta_textarea.focus
  21.     set window.hta_cancel.onclick = getref("hta_cancel")
  22.     set window.hta_ok.onclick = getref("hta_ok")
  23.     set window.document.body.onunload = getref("hta_onunload")
  24.     do until completed > 0
  25.         wscript.sleep 10
  26.     loop
  27.     select case completed
  28.     case 1
  29.         inputboxml = ""
  30.     case 2
  31.         inputboxml = ""
  32.         window.close
  33.     case 3
  34.         inputboxml = window.hta_textarea.value
  35.         window.close
  36.     end select
  37. end function
  38.  
  39. function createwindow()
  40.     rem source http://forum.script-coding.com/viewtopic.php?pid=75356#p75356
  41.     dim signature, shellwnd, proc
  42.     on error resume next
  43.     signature = left(createobject("Scriptlet.TypeLib").guid, 38)
  44.     do
  45.         set proc = createobject("WScript.Shell").exec("mshta ""about:<head><script>moveTo(-32000,-32000);</script><hta:application id=app border=dialog minimizebutton=no maximizebutton=no scroll=no showintaskbar=yes contextmenu=no selection=yes innerborder=no icon=""%windir%\system32\notepad.exe""/><object id='shellwindow' classid='clsid:8856F961-340A-11D0-A96B-00C04FD705A2'><param name=RegisterAsBrowser value=1></object><script>shellwindow.putproperty('" & signature & "',document.parentWindow);</script></head>""")
  46.         do
  47.             if proc.status > 0 then exit do
  48.             for each shellwnd in createobject("Shell.Application").windows
  49.                 set createwindow = shellwnd.getproperty(signature)
  50.                 if err.number = 0 then exit function
  51.                 err.clear
  52.             next
  53.         loop
  54.     loop
  55. end function
  56.  
  57. sub hta_onunload
  58.     completed = 1
  59. end sub
  60.  
  61. sub hta_cancel
  62.     completed = 2
  63. end sub
  64.  
  65. sub hta_ok
  66.     completed = 3
  67. end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement