Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Test for Shift Key
Message
From
26/09/2005 09:15:02
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01052949
Message ID:
01053004
Views:
12
>>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
>
>
>
Thanks Borislav. That does the trick for me!
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Reply
Map
View

Click here to load this message in the networking platform