467,104 Members | 1,003 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

monitoring a pressed key from keyboard

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?


Joćo Correia
Sep 15 '08 #1
  • viewed: 2266
4 Replies

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

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;
Sep 15 '08 #2
Expert Mod 2GB

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


Sep 15 '08 #3
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
Expert Mod 2GB
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.


Sep 15 '08 #5

Post your reply

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

Similar topics

13 posts views Thread by webzila | last post: by
2 posts views Thread by genojoe | last post: by
4 posts views Thread by tidegenerator@tom.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.