Page 1 of 1

Send text with Esc key

Posted: Sun Jan 23, 2011 8:56 pm
by Regis
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

Send text with Esc key

Posted: Sun Jan 23, 2011 8:56 pm
by Regis
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

Send text with Esc key

Posted: Tue Jan 25, 2011 1:05 am
by jvierra
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.