By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,809 Members | 1,999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,809 IT Pros & Developers. It's quick & easy.

monitoring a pressed key from keyboard

P: 63
Hi, I have a script that is allways running, monitoring a folder to see if there is any new file.
i'd like to add to this script something else like "if you want to run this thing, press "a" ".
This option will be allways there. If the user press the key it runs some code.
It have to watch the folder but watch the key either.


How can I do this?

Thnaks,

Joćo Correia
Sep 15 '08 #1
Share this Question
Share on Google+
4 Replies


P: 62
Hi!

download the term TermReadKey( when u a non blocked read will?)

Example:
Expand|Select|Wrap|Line Numbers
  1. ReadMode 4, IN;
  2. $k = "";
  3. #$in = *STDIN;
  4. $in = \*IN; # or *IN or "IN" 
  5. while($k ne "q")
  6. {
  7.  print "Press a key, or \"q\" to stop: ";
  8.  $count=0;
  9.  #print "IN = $in\n";
  10.  $count++ while !defined($k=ReadKey(-1, $in));
  11.  #print "IN2 = $in\n";
  12.  print "\nYou pressed `",makenice($k),"' after the loop rolled over $count times\n";
  13. }
  14. ReadMode 0, IN;
  15.  
Sep 15 '08 #2

numberwhun
Expert Mod 2.5K+
P: 3,503
Arepi,

Please learn to use the code tags. They are necessary in the forums when you are posting code.

Regards,

Jeff
Sep 15 '08 #3

P: 62
Thanks Jeff!

Sorry but I beginner and I don't now what are "code tag" and how can I use them.
Sep 15 '08 #4

numberwhun
Expert Mod 2.5K+
P: 3,503
Thanks Jeff!

Sorry but I beginner and I don't now what are "code tag" and how can I use them.
If you edit the post that you put the code in, you will see the code tags. Also, when you are replying or posting, there is a "Reply Guidelines" box to the right of the reply box that shows you as well.

Regards,

Jeff
Sep 15 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.