Information générale
Titre:
How can I tell what the last pressed key is?
We have a foxprogram that talks to a weighing-scale. At this point we have been using the inkey to make sure the scale weight is read at regular intervals but it is clear that the inkey has somewhat strange behavior.
In order to make sure that we are talking to a scale on a 1/10 of a second basis we used the inkey(0.1) to make sure this worked.
Testing has showed us that the 0.1 interval is not strictly enforced. It may fluctuate from 0.05 to 0.25 even when we are not doing anything else on the pc.
Thinking that the inkey is nothing but a loop we decided to replace inkey with a while-loop. This is what is looks like:
CLEAR
pntimeout = 0.1
?'Timeout ' + STR(pntimeout ,5, 3)
pnSeconds = seconds()
plContinue = .T.
DO WHILE plContinue
DO WHILE .T. and plcontinue and CHRSAW() = .F.
?'waiting...'
IF SECONDS() - pnseconds > pntimeout
EXIT
ENDIF
ENDDO
IF CHRSAW() = .T.
?lastkey() + asc(lastkey() )
* plContinue = .F.
keyboard chr(0) clear
ELSE
ENDIF
ENDDO
The problem I'm now running into is the following.
I want to test if the user is pressing any keys in between and accordingly I want to do some other stuff as well.
I have no problems determining that the user pressed 'a' key. What I can't figure out is 'What key did he/she push'. The lastkey() is not returning what I expect.
Can anyone share light into this.
Thanks in advance,
Ron Brahma
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement