Send text with Esc key

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
Regis
Posts: 2
Joined: Sun Jan 23, 2011 8:56 pm

Send text with Esc key

Post by Regis » Sun Jan 23, 2011 8:56 pm

Hi, The script below is working properly. But i am looking for a way, that the text in the text-field is written to Text.txtwhen the escape key (Esc) is pressed, instead of clicking the Send button. Any help will be highly appreciated._____________________________________________<Script Language="VBScript">Dim fso, oFileSet fso = CreateObject("Scripting.FileSystemObject")Set objShell = CreateObject("WScript.Shell")Sub WriteSet oFile = fso.OpenTextFile("Text.txt",8,true)sTxtArea = document.all("TxtArea").ValueoFIle.Write sTxtAreaMsgBox "The text has been added to Text.txt", 64oFile.closeEnd Sub</SCRIPT><TextArea style="Height:200;Width:400;font-Size:12;color:Black;background-color:bisque;font-weight:Normal;font-family:Microsoft Sans Serif"Name=TxtArea TabOrder=2 Wrap=off></TextArea><!--I would like to change the following line, so that the text is written to Text.txt when the Esc key is pressed--><input type="Button" value="Send" onclick="Write">_____________________________________________Regis

User avatar
Regis
Posts: 2
Joined: Sun Jan 23, 2011 8:56 pm

Send text with Esc key

Post by Regis » Sun Jan 23, 2011 8:56 pm

Hi, The script below is working properly. But i am looking for a way, that the text in the text-field is written to Text.txtwhen the escape key (Esc) is pressed, instead of clicking the Send button. Any help will be highly appreciated._____________________________________________<Script Language="VBScript">Dim fso, oFileSet fso = CreateObject("Scripting.FileSystemObject")Set objShell = CreateObject("WScript.Shell")Sub WriteSet oFile = fso.OpenTextFile("Text.txt",8,true)sTxtArea = document.all("TxtArea").ValueoFIle.Write sTxtAreaMsgBox "The text has been added to Text.txt", 64oFile.closeEnd Sub</SCRIPT><TextArea style="Height:200;Width:400;font-Size:12;color:Black;background-color:bisque;font-weight:Normal;font-family:Microsoft Sans Serif"Name=TxtArea TabOrder=2 Wrap=off></TextArea><!--I would like to change the following line, so that the text is written to Text.txt when the Esc key is pressed--><input type="Button" value="Send" onclick="Write">_____________________________________________Regis

jvierra
Posts: 13882
Joined: Tue May 22, 2007 9:57 am
Contact:

Send text with Esc key

Post by jvierra » Tue Jan 25, 2011 1:05 am

The code works every time you press the escape key. The 'body' element has to hav an id so the keystrokes are caught by the code and filtered.

There is NO html that can do what you ask. It MUST be done in script.

The native language of an HTA is VBScript but you can convert it to JavaScript if you know hoew to use JavaScript event capture.

To filter for a single keystroke the event has to be on the body element.

If the code is not working you copied it wrong. Just place the code inside of a file with an HTA extension and execute the file.


Locked