Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keys Held Down By User 1

Status
Not open for further replies.

craigsboyd

IS-IT--Management
Nov 9, 2002
2,839
US
I want certain code in a prg file to run conditionally based on whether the user is holding down certain keys...like only run this code if user is holding alt+shift down...I do not mean that if the user hits those keys that I then run that code...i mean as the processing is proceeding and it comes to the conditional if statement if the user is not holding the desired keys down then it won't run the code. Slighthaze = NULL
 
slighthaze

Check out the WinAPI call GetKeyState()
FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Hi

Alt, Shift, Ctrl keys hold special significance.

You can detect the pressing of the keys along with other recognisable keys thru the KeyPress event. But their pressing alone can only be detected using some WINAPI routines.

Coupled with a timer and the WinAPi you can detect these.

Alt key will respond to INKEY() or can be found using LASTKEY(). But Alt key has its significance.

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Thank you for the responses Chris and Ramani.

Chris you make a guy go "Why the heck didn't i think of that!!??" :) Good looking out!

Slighthaze = NULL
 
Chris and Ramani,

Works like a charm, if you want run this from a prg and hold down ctrl+alt+s...


Messagebox("READY?")
Declare Integer GetKeyState In user32;
INTEGER vKey

#DEFINE VK_MENU 0x12
#DEFINE VK_CONTROL 0x11
#DEFINE VK_S 0x53

nKey = GetKeyState(VK_MENU)
If nKey <> 0
nKey = GetKeyState(VK_CONTROL)
If nKey <> 0
nKey = GetKeyState(VK_S)
If nKey <> 0
MESSAGEBOX(&quot;ALL 3 KEYS PRESSED!&quot;)
Clear Dlls GetKeyState
RETURN .t.
EndIf
EndIf
EndIf

MESSAGEBOX(&quot;NOT ALL 3 KEYS PRESSED!&quot;)

Clear Dlls GetKeyState

RETURN .t.


...Thank you again for your help. Slighthaze = NULL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top