Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Test for Shift Key
Message
 
To
26/09/2005 06:58:52
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01052949
Message ID:
01052967
Views:
9
Thanks Fabio,
Because I never need this, I never tryed it.
I'll think for other example :o(


>>>Hi All. Is it possible to test for just the shift key being held down? Or the Alt key or the Ctrl key - just by themselves?
>>
>>Test this:
>>
>>
>>#define VK_SHIFT          0x10
>>#define VK_CONTROL        0x11
>>#define VK_MENU           0x12
>>#define PRESSED           0x07
>>
>>DECLARE INTEGER GetKeyboardState IN WIN32API STRING @
>>
>>DO WHILE .t.
>>   m1 = REPLICATE(CHR(0),255)
>>   wait WINDOW "" TIMEOUT 0.5
>>   GetKeyboardState(@m1)
>>   ? "Shift",ASC(SUBSTR(m1,VK_SHIFT+1,1)), BITTEST(ASC(SUBSTR(m1,VK_SHIFT+1,1)),PRESSED)
>>   ? "Control",ASC(SUBSTR(m1,VK_CONTROL+1,1)), BITTEST(ASC(SUBSTR(m1,VK_CONTROL+1,1)),PRESSED)
>>   ? "Alt",ASC(SUBSTR(m1,VK_MENU+1,1)), BITTEST(ASC(SUBSTR(m1,VK_MENU+1,1)),PRESSED)
>>   IF LASTKEY() == 27
>>      EXIT
>>   ENDIF
>>ENDDO
>>
>>
>>
>
>Hi Borislav,
>because Windows is not a RTOS, the queue it is without time.
>Then
>- you cannot known the duration of the hold key state
>- GetKeyboardState return the state of the queue,
>not the state of the keyboard.
>
>Result, if your system is overloaded you can read down when the key is up.
>
>A simple example simulation:
>the keys are pressed with distance of time than at least 1 second,
>but when VFP elaborates them, they appear pressed in the same ms.
>If you uses GetKeyboardState on this context
>you could have a distorted interaction.
>
>PUBLIC oform1
>
>oform1=NEWOBJECT("form1")
>oform1.Show
>RETURN
>
>DEFINE CLASS form1 AS form
>
>	PROCEDURE Click
>		_VFP.AutoYield=.T.
>		FOR k=1 TO 5
>			? "down",SECONDS()
>			KEYBOARD '{ENTER}' PLAIN
>			FOR j=1 TO 20000000
>			NEXT
>		NEXT
>	ENDPROC
>
>
>	PROCEDURE KeyPress
>		LPARAMETERS nKeyCode, nShiftAltCtrl
>		? SECONDS()
>	ENDPROC
>
>
>ENDDEFINE
>
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform