Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

InputBox on top

772 views
Skip to first unread message

Rob Hegt

unread,
Nov 25, 2004, 9:34:10 AM11/25/04
to
I have a COM server (out-of-proc) that starts a VBscript by means of the
script control.
The script needs to display an input box. The box shows, but it is not on
top. Is there any
way I can make it to appear on top automatically, from within the script?

Alternatively, does anyone know of a tool that would spy on the windows and
automatically
raise windows with a given title (or title pattern)?

TIA,
Rob Hegt


Bill James

unread,
Nov 25, 2004, 2:43:53 PM11/25/04
to
Since vbscript pauses once an inputbox is presented, it should be on top of any windows opened by the script, unless an open program has an always on top setting in it's code. You might want to try minimize all windows right before the inputbox command, or if you are shell running the program that is on top, perhaps add the flag to open it minimized.

--

Bill James
Microsoft MVP - Shell/User

Windows VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/

"Rob Hegt" <som...@somewhere.org> wrote in message news:41a5...@ottunt1.eu.biomerieux.com...

Torgeir Bakken (MVP)

unread,
Nov 26, 2004, 2:03:13 PM11/26/04
to
Rob Hegt wrote:

> I have a COM server (out-of-proc) that starts a VBscript by means of the
> script control.
> The script needs to display an input box. The box shows, but it is not on
> top. Is there any
> way I can make it to appear on top automatically, from within the script?

Hi

With vbSystemModal maybe:

MsgBox "some text", vbInformation + vbSystemModal, "some title"

--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Bill James

unread,
Nov 26, 2004, 3:36:17 PM11/26/04
to
The OP is asking about InputBox.

--

Bill James
Microsoft MVP - Shell/User

Windows VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message news:u4ZLar%230EH...@TK2MSFTNGP10.phx.gbl...

Torgeir Bakken (MVP)

unread,
Nov 26, 2004, 4:13:05 PM11/26/04
to
Bill James wrote:

> The OP is asking about InputBox.
>

Oops!

Torgeir Bakken (MVP)

unread,
Nov 26, 2004, 4:17:26 PM11/26/04
to
Rob Hegt wrote:

> I have a COM server (out-of-proc) that starts a VBscript by means of the
> script control.
> The script needs to display an input box. The box shows, but it is not on
> top. Is there any
> way I can make it to appear on top automatically, from within the script?

Hi

Disregard my first post, my brain was set for MsgBox.

Using AppActivate from a second script (that e.g. the first script
creates and launches) is an option. Here is an example:


'--------------------8<----------------------
Const OpenAsASCII = 0
Const OverwriteIfExist = -1

sTitle = "Some title" ' Title to be used in InputBox

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFile = oFSO.GetSpecialFolder(2).ShortPath & "\" & oFSO.GetTempName & ".vbs"
Set fFile = oFSO.CreateTextFile(sFile, OverwriteIfExist, OpenAsASCII)
fFile.WriteLine "Set oShell = CreateObject(""WScript.Shell"")"
fFile.WriteLine "Do While Not oShell.AppActivate(""" & sTitle & """)"
fFile.WriteLine " WScript.Sleep 200"
fFile.WriteLine "Loop"
fFile.Close

oShell.Run "wscript.exe " & sFile, 1, False
sInput = InputBox("something", sTitle)
oFSO.DeleteFile sFile
'--------------------8<----------------------

Bill James

unread,
Nov 27, 2004, 12:31:29 AM11/27/04
to
I confess, I had a response similar to yours ready to send when I noticed the context and backed out.

--

Bill James
Microsoft MVP - Shell/User

Windows VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message news:%23Wuu%23z$0EHA...@TK2MSFTNGP14.phx.gbl...

Rob Hegt

unread,
Dec 1, 2004, 5:00:23 AM12/1/04
to
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:uL95a2$0EHA...@TK2MSFTNGP14.phx.gbl...
<stuff deleted...>

> '--------------------8<----------------------
> Const OpenAsASCII = 0
> Const OverwriteIfExist = -1
>
> sTitle = "Some title" ' Title to be used in InputBox
>
> Set oShell = CreateObject("WScript.Shell")
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> sFile = oFSO.GetSpecialFolder(2).ShortPath & "\" & oFSO.GetTempName &
".vbs"
> Set fFile = oFSO.CreateTextFile(sFile, OverwriteIfExist, OpenAsASCII)
> fFile.WriteLine "Set oShell = CreateObject(""WScript.Shell"")"
> fFile.WriteLine "Do While Not oShell.AppActivate(""" & sTitle & """)"
> fFile.WriteLine " WScript.Sleep 200"
> fFile.WriteLine "Loop"
> fFile.Close
>
> oShell.Run "wscript.exe " & sFile, 1, False
> sInput = InputBox("something", sTitle)
> oFSO.DeleteFile sFile
> '--------------------8<----------------------
>

Unfortunately, this code does run but not help. The input box is created,
but it
does not show on top, but only in the task bar.

Thanks anyway,
Rob Hegt


Torgeir Bakken (MVP)

unread,
Dec 1, 2004, 5:09:23 AM12/1/04
to
Rob Hegt wrote:

> Unfortunately, this code does run but not help.
> The input box is created, but it
> does not show on top, but only in the task bar.

Hi

AppActivate have it's limitations, you may want to try AutoItX in
the second script instead, it has a much better Appactivate handling.

More about AutoIt/AutoItX here:
http://groups.google.com/groups?selm=OuXrBqBuEHA.3188%40TK2MSFTNGP15.phx.gbl

Miyahn

unread,
Dec 1, 2004, 8:31:37 AM12/1/04
to
"Rob Hegt" wrote in message news:41ad9241$1...@ottunt1.eu.biomerieux.com

> Unfortunately, this code does run but not help.
> The input box is created,
> but it does not show on top, but only in the task bar.

How about this "mumbo jumbo"?
(use before showing inputbox)

With CreateObject("WScript.Shell")
.SendKeys "{F10}{ESC}", True
End With

--
Miyahn (Masataka Miyashita) JPN
Microsoft MVP (Office Systems - Excel)
HQF0...@nifty.ne.jp

0 new messages