From: Tom Lavedas on
On Jun 11, 4:11 am, "Dave \"Crash\" Dummy" <inva...(a)invalid.invalid>
wrote:
> Maw wrote:
> > On 10 Giu, 19:28, Tom Lavedas <tglba...(a)verizon.net> wrote:
> >> On Jun 10, 11:38 am, Maw <maw81...(a)gmail.com> wrote:
>
> >>> Hi all, i want find a way to show in a popup or in ie windows a
> >>> status message of the script: .....part of the some script in a
> >>> loop For Each objUser in objOldOU strstreetAddress =
> >>> objUser.Get("streetAddress") 'wscript.echo strstreetAddress
> >>> Select Case (strstreetAddress) Case "MI- Europa" oudest =
> >>> "LDAP://ou=Utenti,ou=Europa,ou=Sedi," & varDomainNC objUser.Put
> >>> "scriptPath", "europa.cmd" MESSAGE = "SELECT CASE 1" Case
> >>> "Cavallotti" oudest = "LDAP://ou=Utenti,ou=Cavallotti,ou=Sedi," &
> >>> varDomainNC objUser.Put "scriptPath", "cavallotti.cmd" MESSAGE =
> >>> "SELECT CASE 2" Case "Broletto" oudest =
> >>> "LDAP://ou=Utenti,ou=Broletto,ou=Sedi," & varDomainNC objUser.Put
> >>> "scriptPath", "broletto.cmd" MESSAGE = "SELECT CASE 3" Case "Mi -
> >>> Sempione" oudest = "LDAP://ou=Utenti,ou=Sempione,ou=Sedi," &
> >>> varDomainNC objUser.Put "scriptPath", "sempione.cmd" MESSAGE =
> >>> "SELECT CASE 4" End Select objUser.SetInfo Set objNewOU =
> >>> GetObject(oudest) WSCRIPT.ECHO MESSAGE objNewOU.MoveHere
> >>> objUser.ADsPath, vbNullString It's possible open a message and
> >>> close it after some second without the user click on some button?
> >>>  Thx in advance. Maw
> >> The simplest solution if the Wscript.Shell Popup function ...
>
> >> Set WshShell = CreateObject("WScript.Shell") WshShell.Popup "Your
> >> message here", 5, "Title", vbOkay + vbExclamation
>
> >> See the WSH documentation for more information. WSH 5.6+
> >> documentation download (URL all one
> >> line)http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207...
>
> >> The other approach is to build your own adaptable display through
> >> the IE document object model.  I've posted a number of examples
> >> here in the past.  Try a groups.google search.
> >> _____________________ Tom Lavedas
>
> > Hi, i like the WshShell.Popup but i don't want the button, it's
> > possible?
>
> No.
>
> > And HTA for me it's a new way, i don't know the code!!!
>
> It is the same as a scripted web page except with a HTA extension
> instead of HTM, and you have all the privileges of a VBS script.http://en..wikipedia.org/wiki/HTML_Application
> --
> Crash
>
> "When you get to a fork in the road, take it."
> ~ Yogi Berra ~

Here is a no button box using IE, which can be integrated into an
existing VBS script ...

sMessage = "This is your message"
nobtnbox sMessage, 3, "Title goes here"
nobtnbox "<b>" & sMessage & " emphasized", 3, "Title goes here"
nobtnbox "<font color=red>" & sMessage & "in red", 3, "Title goes
here"

Sub NoBtnBox(sMsg, nWait, sTitle)
Dim Height, Width, oIE

' Default values ...
height = 100 : width = 400

set oIE = CreateObject("InternetExplorer.Application")
With oIE
.RegisterAsDropTarget = False
.toolbar = false : .statusbar = false
.menubar = false : .addressbar = false
.width = Width : .height = Height
.Navigate "about:blank"
Do Until .ReadyState = 4 : WScript.Sleep 50 : Loop
With .document
.open
.write "<html><head><title>MsgBox ...</title></head>" _
& "<body id=bdy bgColor=silver scroll=no " _
& "style='font-family:sans-serif'><center>" _
& "<span id=msg></spam></center></body></html>"
.close
Do Until oIE.ReadyState = 4 : WScript.Sleep 50 : Loop
With .parentWindow.screen
oIE.left = (.width - oIE.width )\ 2
oIE.top = (.height- oIE.height)\ 2
End With
.title = sTitle
.all.msg.innerHTML = sMsg
End With ' document
.Visible = True
CreateObject("Wscript.Shell").AppActivate "MsgBox ..."
End With ' IE
wsh.sleep nWait * 1000
oIe.Quit
End sub

Unfortunately, IE versions of 7 and above prohibit removal of the
title bar and recent Hotfixes added an http:// prefix for all URLs,
even "about:blank". It can actually be done using an HTA that is
built on-the-fly, but it's way too complicated. The only reason a
person would do that would be to get rid of that ugly title bar. In
general, it's probably not worth the bother - it may be better to go
out and find a third party control that does it easier and better.
_____________________
Tom Lavedas
From: Tom Lavedas on
On Jun 11, 11:01 am, Tom Lavedas <tglba...(a)verizon.net> wrote:
{snip}

> It can actually be done using an HTA that is
> built on-the-fly, but it's way too complicated.  The only reason a
> person would do that would be to get rid of that ugly title bar.  In
> general, it's probably not worth the bother - it may be better to go
> out and find a third party control that does it easier and better.
> _____________________
> Tom Lavedas

It turned out to be much easier than I thought, thanks to a
trick"Mayayana" posted here not too long ago ...

set oMsgBox = NewMsgBox("lightgrey")
oMsgBox.document.title = "No Button Message Box"
oMsgBox.msg.innerText = "A new message"
wsh.sleep 5000
oMsgBox.close

Function NewMsgBox(sBgColor)
Dim IE, HTA

with CreateObject("WScript.Shell")
.Run "MSHTA.EXE " _
& """javascript:new ActiveXObject('InternetExplorer.Application')"
_
& ".PutProperty('ID1',window);""", 1, False

do until .AppActivate("javascript:new")
WScript.sleep 50
loop
end with ' Shell

For Each IE In CreateObject("Shell.Application").Windows
If IsObject(IE.GetProperty("ID1")) Then
Set HTA = IE.GetProperty("ID1")
HTA.resizeTo 300,100 : HTA.moveto 500, 400
with HTA.document
.write "<HTA:Application contextMenu=no border=dialog " _
& "minimizebutton=no maximizebutton=no sysmenu=no />" _
& "<body scroll=no style='background-color:" _
& sBgColor & ";font:normal 12pt Arial'>" _
& "<center><span id=msg>&nbsp;</span><center></body>"
end with
IE.quit
Exit For
End If
Next

set NewMsgBox = HTA

End Function

This is intended as a bare bones prototype that can be modified to
meet particular needs. I built this version to pass the HTA object
back to the calling program. This allows full DHTML access to the
entire DOM, making for the highest possible versatility. The function
can be tailored to do the whole job, retuning only when the message
timeout is reached.

The big advantage of this approach is the removal of all of the IE
'chrome'. The disadvantage is that the initial HTA frame flashes onto
the screen, before it is resized to the programmed sizes. This is
usually suppressed in a standalone HTA by placing a 'resizeTo'
statement at the very top of the file before any other definitions or
scripting. I haven't figured out how to emulate that here.
_____________________
Tom Lavedas
From: James Whitlow on
"Tom Lavedas" <tglbatch(a)verizon.net> wrote in message
news:422ff750-711d-44f5-a3bb-4adba77b2bd2(a)k39g2000yqd.googlegroups.com...
On Jun 11, 11:01 am, Tom Lavedas <tglba...(a)verizon.net> wrote:
{snip}
> It turned out to be much easier than I thought, thanks to a
> trick"Mayayana" posted here not too long ago ...
>
> set oMsgBox = NewMsgBox("lightgrey")
> oMsgBox.document.title = "No Button Message Box"
> oMsgBox.msg.innerText = "A new message"
> wsh.sleep 5000
> oMsgBox.close
>
> Function NewMsgBox(sBgColor)
> Dim IE, HTA
>
> with CreateObject("WScript.Shell")
> .Run "MSHTA.EXE " _
> & """javascript:new ActiveXObject('InternetExplorer.Application')"
> _
> & ".PutProperty('ID1',window);""", 1, False
>
> do until .AppActivate("javascript:new")
> WScript.sleep 50
> loop
> end with ' Shell
>
> For Each IE In CreateObject("Shell.Application").Windows
> If IsObject(IE.GetProperty("ID1")) Then
> Set HTA = IE.GetProperty("ID1")
> HTA.resizeTo 300,100 : HTA.moveto 500, 400
> with HTA.document
> .write "<HTA:Application contextMenu=no border=dialog " _
> & "minimizebutton=no maximizebutton=no sysmenu=no />" _
> & "<body scroll=no style='background-color:" _
> & sBgColor & ";font:normal 12pt Arial'>" _
> & "<center><span id=msg>&nbsp;</span><center></body>"
> end with
> IE.quit
> Exit For
> End If
> Next
>
> set NewMsgBox = HTA
>
> End Function
>
> This is intended as a bare bones prototype that can be modified to
> meet particular needs. I built this version to pass the HTA object
> back to the calling program. This allows full DHTML access to the
> entire DOM, making for the highest possible versatility. The function
> can be tailored to do the whole job, retuning only when the message
> timeout is reached.
>
> The big advantage of this approach is the removal of all of the IE
> 'chrome'. The disadvantage is that the initial HTA frame flashes onto
> the screen, before it is resized to the programmed sizes. This is
> usually suppressed in a standalone HTA by placing a 'resizeTo'
> statement at the very top of the file before any other definitions or
> scripting. I haven't figured out how to emulate that here.

I am not sure if it is in scope for what OP asked for, but you can alter
this to have a message box with a timeout that does not stop the script by
using the 'execScript' method. Just remove the 'wsh.sleep 5000' &
'oMsgBox.close' lines from the above script and replace them with:

oMsgBox.document.parentWindow.execScript _
"setTimeout ""window.close()"", 5000", "VBScript"


From: Tom Lavedas on
On Jun 11, 7:40 pm, "James Whitlow" <jwhitlow.60372...(a)bloglines.com>
wrote:
> "Tom Lavedas" <tglba...(a)verizon.net> wrote in message
>
> news:422ff750-711d-44f5-a3bb-4adba77b2bd2(a)k39g2000yqd.googlegroups.com...
> On Jun 11, 11:01 am, Tom Lavedas <tglba...(a)verizon.net> wrote:
> {snip}
>
> > It turned out to be much easier than I thought, thanks to a
> > trick"Mayayana" posted here not too long ago ...
>
> > set oMsgBox = NewMsgBox("lightgrey")
> > oMsgBox.document.title = "No Button Message Box"
> > oMsgBox.msg.innerText = "A new message"
> > wsh.sleep 5000
> > oMsgBox.close
>
> > Function NewMsgBox(sBgColor)
> > Dim IE, HTA
>
> >   with CreateObject("WScript.Shell")
> >     .Run "MSHTA.EXE " _
> >     & """javascript:new ActiveXObject('InternetExplorer.Application')"
> > _
> >     & ".PutProperty('ID1',window);""", 1, False
>
> >     do until .AppActivate("javascript:new")
> >       WScript.sleep 50
> >     loop
> >   end with ' Shell
>
> >   For Each IE In CreateObject("Shell.Application").Windows
> >     If IsObject(IE.GetProperty("ID1")) Then
> >       Set HTA = IE.GetProperty("ID1")
> >       HTA.resizeTo 300,100 : HTA.moveto 500, 400
> >       with HTA.document
> >         .write "<HTA:Application contextMenu=no border=dialog " _
> >              & "minimizebutton=no maximizebutton=no sysmenu=no />" _
> >              & "<body scroll=no style='background-color:" _
> >              & sBgColor & ";font:normal 12pt Arial'>" _
> >              & "<center><span id=msg>&nbsp;</span><center></body>"
> >       end with
> >       IE.quit
> >       Exit For
> >     End If
> >   Next
>
> >   set NewMsgBox = HTA
>
> > End Function
>
> > This is intended as a bare bones prototype that can be modified to
> > meet particular needs.  I built this version to pass the HTA object
> > back to the calling program.  This allows full DHTML access to the
> > entire DOM, making for the highest possible versatility.  The function
> > can be tailored to do the whole job, retuning only when the message
> > timeout is reached.
>
> > The big advantage of this approach is the removal of all of the IE
> > 'chrome'.  The disadvantage is that the initial HTA frame flashes onto
> > the screen, before it is resized to the programmed sizes.  This is
> > usually suppressed in a standalone HTA by placing a 'resizeTo'
> > statement at the very top of the file before any other definitions or
> > scripting.  I haven't figured out how to emulate that here.
>
>   I am not sure if it is in scope for what OP asked for, but you can alter
> this to have a message box with a timeout that does not stop the script by
> using the 'execScript' method. Just remove the 'wsh.sleep 5000' &
> 'oMsgBox.close' lines from the above script and replace them with:
>
> oMsgBox.document.parentWindow.execScript _
>  "setTimeout ""window.close()"", 5000", "VBScript"

Yes, great idea.
______________________
Tom Lavedas
From: Maw on
I all,
i have find this easy solution:

Set objExplorer =
WScript.CreateObject("InternetExplorer.Application","IE_")
objExplorer.Navigate "about:blank"
' size of window
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 100
objExplorer.Left = 0
objExplorer.Top = 0
' window visible and starting message
objExplorer.Visible = 1
objExplorer.Document.Body.scroll = "no"

and when you need to print the message i put the code below:
objExplorer.Document.Body.InnerHTML = "Connection to AD..."
wscript.sleep(500)

it's easy but good to understand where is the script.

Only one question: It's possible remove the title bar???

Thx to all for the reply.

bye