You are here: PSPad forum > English discussion forum > in vbs script, SLEEP don't manage "ProcessMessages"

in vbs script, SLEEP don't manage "ProcessMessages"

#1 in vbs script, SLEEP don't manage "ProcessMessages"

Posted by: candide | Date: 2019-01-10 21:08 | IP: IP Logged

using PSPad from a long time, i am looking at VBS to add a specific feature but i am stuck around SLEEP feature.
when a VBS script is running, PSPad is stuck and it is normal, but when i am using SLEEP 100 command in script, during this time, control is given to PSPAD and PSPAD should manage all events but it doesn't.
Also, when i try to run a VBS script opening a windows and waiting for an event in a loop with SLEEP 100, script is stuck because events are not managed... in fact SLEEP is just a temporization but don't integrate ProcessMessages in PSPad.

your feedback will be welcome, and thanks for this wonderful tool

script tested :
'option explicit
const module_name = "hta test" 'this name must be unique !!!
const module_desc = "test d'un hta" 'script description
const module_ver = "0.001" 'version
dim completed

sub main
msgbox inputboxml("Enter text:", "Multiline inputbox via HTA", "Enter your name : " & vbcrlf & "Enter your Age : " & vbcrlf &_
"Enter email id you want to send : " & vbcrlf & "Enter Subject : " & vbcrlf & "Enter Email Body : " )
end sub

function inputboxml(prompt, title, defval)
set window = createwindow()
completed = 0
defval = replace(replace(replace(defval, "&", "&amp;"), "<", "&lt;"), ">", "&gt;")
with window
with .document
.title = title = "buttonface" = "consolas, courier new" = "8pt"
.body.innerhtml = "<div><center><nobr>" & prompt & "</nobr><br><br></center><textarea id='hta_textarea' style='font-family: consolas, courier new; width: 100%; height: 400px;'>" & 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>"
end with
.resizeto 550, 550
.moveto 100, 100
end with
set window.hta_cancel.onclick = getref("hta_cancel")
set window.hta_ok.onclick = getref("hta_ok")
set window.document.body.onunload = getref("hta_onunload")
do until completed > 0
sleep 10
select case completed
case 1
inputboxml = ""
case 2
inputboxml = ""
case 3
inputboxml = window.hta_textarea.value
end select
end function

function createwindow()
rem source
dim signature, shellwnd, proc
on error resume next
signature = left(createobject("Scriptlet.TypeLib").guid, 38)
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>""")
if proc.status > 0 then exit do
for each shellwnd in createobject("Shell.Application").windows
set createwindow = shellwnd.getproperty(signature)
if err.number = 0 then exit function
end function

sub hta_onunload
completed = 1
end sub

sub hta_cancel
completed = 2
end sub

sub hta_ok
completed = 3
end sub

sub Init
addMenuItem "testscript" ,"test" , "main"
end sub

Options: Reply | Quote | Up ^

#2 Re: in vbs script, SLEEP don't manage "ProcessMessages"

Posted by: pspad | Date: 2019-02-06 18:35 | IP: IP Logged

It was fixed in current PSPad build

Options: Reply | Quote | Up ^

Editor PSPad - freeware editor, © 2001 - 2023 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR