AllExperts > VB Script 
Search      
VB Script
Volunteer
Answers to thousands of questions
 Home · More VB Script Questions · Answer Library  · Encyclopedia ·
More VB Script Answers
Question Library

Ask a question about VB Script
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Subbu
Expertise
I can answer VB Script questions which are related to Visual Basic / VBA / QTP Scripts.

Experience
8 Years

Education/Credentials
Master of Computer Applications

Awards and Honors
Established Member from QA Forums and Brainbench certification

 
   

You are here:  Experts > Computing/Technology > Basic > VB Script > how to get which key has been pressed.

VB Script - how to get which key has been pressed.


Expert: Subbu - 9/10/2009

Question
QUESTION: hi Subbu,

I wants to know about how can i get which key has been pressed from VB script (except input box function).

Regards
Biswajit.

ANSWER: First I need to know where is the Focus?

I mean, is focus on Form/edit box/some object?

You can use KeyDown, KeyPress or KeyUp event on focus object.

Let me know if you have any questions.

Subbu.

---------- FOLLOW-UP ----------

QUESTION: the schenerio is like this-the vbscript will run background.it will show in task manager.the focus may be desktop, sometime it may be ie application.

ANSWER: Are you executing Task Manager as a shell from VB Script?

Is your VB Script is a TSR (Terminate and Stay Resident) program?





---------- FOLLOW-UP ----------

QUESTION: No. I am not executing Task Manager as a Shell from VB Script. i will run the vbscript the script will copy files from one location to another location non interactively. but only when i will press the esc key or some other key(say Q) then the copy operation will aborted.

Thanks.
Biswajit.

Answer
Now I understand your question.

When you run the vbscript to copy files from one location to another just display a Form with Model dialog (it means focus should always on the Form).

If user try to remove the focus using mouse write some code on LostFocus event.

If user try to type some key when focus is on the Form write some code on KeyUp / KeyDown event.

It will solve your problem 100%

Let me know if you have any questions.

Subbu.


Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.