Groups | Search | Server Info | Login | Register
Groups > alt.comp.lang.vbscript > #36
| From | Paul <nospam@needed.invalid> |
|---|---|
| Newsgroups | alt.comp.lang.vbscript, alt.comp.os.windows-xp, alt.windows7.general |
| Subject | Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? |
| Date | 2025-12-13 17:14 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <10hkofo$fdor$1@dont-email.me> (permalink) |
| References | <10gcoac$2l8do$1@dont-email.me> <10hk0bk$5c2m$2@toylet.eternal-september.org> <10hk5i8$7mqo$1@dont-email.me> <10hkndd$f0eu$1@dont-email.me> |
Cross-posted to 3 groups.
On Sat, 12/13/2025 4:55 PM, Paul wrote:
> On Sat, 12/13/2025 11:51 AM, R.Wieser wrote:
>> Mr. Man-wai Chang,
>>
>>> https://www.google.com/search?q=vbscript+OpenTextFile+CreateTextFile+console{snip}
>>
>> [quote=me]
>> I can't get those to work using OpenTextFile / CreateTextFile.
>> [/quote]
>>
>> And yes, I did search for the solution before posting here. Alas, no dice.
>>
>> Regards,
>> Rudy Wieser
>>
>>
>
> I asked CoPilot to write me something.
>
> Prepare a vbscript CSCRIPT program which opens a window,
> accepts text input from the terminal session, then displays
> "You typed " followed by the text string, placing the text
> string on CONOUT and within the opened window, then waits
> for an additional carriage return to exit the program.
CoPilot actually commented at the end of the response, about the
missing non-blocking part. Why it didn't do this in the first place,
I don't know. Notice that the GUI now, isn't what you envisioned.
But at least the program "meets specification" from an "intentions
point of view". I don't know if this works for you though.
What is the "GOTO 0" thing ? I don't see a magic label, so this
might be a hallucination of some sort.
*******************************************************************
' Save as input_echo3.vbs
' Run with: cscript //nologo input_echo3.vbs
Option Explicit
Dim WshShell, userInput, dummy, htmlFile, fso, ts
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
' Prompt for input from terminal
WScript.StdOut.Write "Type something: "
userInput = WScript.StdIn.ReadLine
' Echo to console
WScript.StdOut.WriteLine "You typed " & userInput
' Create a temporary HTML file for the window
htmlFile = fso.GetSpecialFolder(2) & "\input_echo.html" ' Temp folder
Set ts = fso.CreateTextFile(htmlFile, True)
ts.WriteLine "<html><head><title>Input Echo</title></head>"
ts.WriteLine "<body style='display:flex;align-items:center;justify-content:center;"
ts.WriteLine "height:100%;font-family:sans-serif;font-size:16pt;'>"
ts.WriteLine "You typed <b>" & Replace(userInput,"'","'") & "</b>"
ts.WriteLine "<script>"
ts.WriteLine "window.name='EchoWin';"
ts.WriteLine "</script>"
ts.WriteLine "</body></html>"
ts.Close
' Launch mshta to show the window
WshShell.Run "mshta.exe """ & htmlFile & """", 1, False
' Wait for carriage return before exit
WScript.StdOut.Write "Press ENTER to exit..."
dummy = WScript.StdIn.ReadLine
' Close the window by sending a command to mshta
On Error Resume Next
WshShell.AppActivate "Input Echo"
WshShell.SendKeys "%{F4}" ' Alt+F4 to close
On Error GoTo 0
' Clean up temp file
On Error Resume Next
fso.DeleteFile htmlFile
On Error GoTo 0
*******************************************************************
Paul
Back to alt.comp.lang.vbscript | Previous | Next — Previous in thread | Next in thread | Find similar
vbscript CSCRIPT howto : writie to screen and read from keyboard ? "R.Wieser" <address@is.invalid> - 2025-11-28 19:05 +0100
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2025-12-13 23:22 +0800
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "R.Wieser" <address@is.invalid> - 2025-12-13 17:51 +0100
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? Paul <nospam@needed.invalid> - 2025-12-13 16:55 -0500
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? Paul <nospam@needed.invalid> - 2025-12-13 17:14 -0500
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "R.Wieser" <address@is.invalid> - 2025-12-14 07:09 +0100
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "R.Wieser" <address@is.invalid> - 2025-12-14 07:04 +0100
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2025-12-14 16:21 +0800
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "R.Wieser" <address@is.invalid> - 2025-12-14 11:37 +0100
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? JJ <jj4public@gmail.com> - 2025-12-14 08:00 +0700
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "R.Wieser" <address@is.invalid> - 2025-12-14 07:28 +0100
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2025-12-14 16:16 +0800
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "R.Wieser" <address@is.invalid> - 2025-12-14 11:20 +0100
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? JJ <jj4public@gmail.com> - 2025-12-15 01:36 +0700
Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ? "R.Wieser" <address@is.invalid> - 2025-12-14 20:45 +0100
csiph-web