1. Re: Detecting if the shift, control or alt keys are depressed
- Posted by andy at systemzone.freeserve.co.uk Sep 25, 2003
- 377 views
Hello Derek, Thanks for this code snippet as it is the API version that I'm after. I won't get a chance to test this for a few days but I'm sure it'll work first time. Thanks to Bernie and Don for their input as well. Much appreciated. Regards, Andy Cranston. At 16:13 25/09/03 +1000, you wrote: > > >----- Original Message ----- >From: <andy at systemzone.freeserve.co.uk> >To: "EUforum" <EUforum at topica.com> >Sent: Thursday, September 25, 2003 4:32 AM >Subject: Detecting if the shift, control or alt keys are depressed with exw.exe > > >> Hello Euphorians, >> >> I want to code up a function to report if the shift, control or alt keys >> are currently depressed by the user. I'm guessing I need to access a >> function (or two) within a standard windows supplied DLL. >> >> Any clues on where to start greatly appreciated. >> > >If using win32lib, just call getKeyState() like this ... > > if getKeyState(VK_SHIFT) then > -- shift key is pressed ... > elsif getKeyState(VK_CONTROL) then > -- Control key > elsif getKeyState(VK_MENU) then > -- Alt key > end if > >If using API directly... > >constant dllUser32 = open_dll("user32.dll") > apiGetKeyState = define_c_func(dllUser2, "GetKeyState", {C_UINT}, C_UNIT) > >global function getKeyState( atom key ) > > -- return the state Shift, Control, or Menu keys > return (floor( c_func( apiGetKeyState, {key} ) / 2 ) != 0) > >end function > >-- >Derek > >--^---------------------------------------------------------------- >This email was sent to: andy at systemzone.freeserve.co.uk > > >TOPICA - Start your own email discussion group. FREE! > >