cancel
Showing results for 
Search instead for 
Did you mean: 

Inputbox is not active

0 Kudos


Hello,

in a vbs script I want the date to be entered:

DatumAnfang = Inputbox("Datum der Abfrage (TT/MM/JJJJ)?")

It works perfect with one little problem: even when the inputbos appears it's not active. I have to click into the box and after that I can enter the date.

How do I make the box active, so I can enter the date without using the mouse?

Best regards,

Lutz

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hello Stefan,

I didn't try it yet, but you tell me the reason for using two scripts?
And what is this line doing :

CreateObject("Wscript.Shell").Run "wscript.exe " & sExternalAppactivateVbs

Thanks,

Lutz

stefan_schnell
Active Contributor
0 Kudos

Hello Lutz,

sorry for my late reply - vacation.

The line

CreateObject("Wscript.Shell").Run "wscript.exe " & sExternalAppactivateVbs

starts another instance of Windows Scripting Host and executes a script independently from the running script.

And I think this is the reason for this way, the independent setting of the window in the foreground. On this way you activate your window definitely.

Cheers

Stefan


stefan_schnell
Active Contributor
0 Kudos

Hello Lutz,

you can find an answer to your question here.

Here the solution from Torgeir Bakken:

<Snip>

First script to open the input box:

sExternalAppactivateVbs = "AppactivateInputBox.vbs"
CreateObject("Wscript.Shell").Run "wscript.exe " & sExternalAppactivateVbs
InputBox "nom", "My unique title"

Second script AppactivateInputBox.vbs:

Set oShell = CreateObject("Wscript.Shell")
Do
  WScript.Sleep 200
  i = i + 1
  If i = 25 Then Exit Do
Loop Until oShell.Appactivate("My unique title")

<Snap>

Let us know the result.

Cheers
Stefan