Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reviving the Scroll Lock
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00290236
Message ID:
00290279
Views:
24
>I appreciate the reply, and have played with it for a while... Here's what I came up with...
>
>#DEFINE VK_SCROLL 0x92
>DECLARE INTEGER GetKeyboardState IN Win32API STRING @lpCodes
>lccodes = SPACE(256)
>= GetKeyboardState(@lccodes)
>
>lnSetting = ASC(SUBSTR(lccodes,vk_scroll,1))
>lnSetting = IIF(lnSetting=0,1,0)
>lccodes = SUBSTR(lccodes,1,(vk_scroll)-1) + ;
> CHR(lnSetting) + SUBSTR(lccodes,(vk_scroll)+1,LEN(lccodes))
>
>This grabs the setting, and changes it from 1>0 or 0>1 depending. My next question is this... I tried to add in a SetKeyboardState with the new lccodes, but kept receiving the message 'Too many parameters.'. I declared it the same way and tried to run it the same way as GetKeyboardState, but it failed. Am I forgetting something ?
>
>Thanks,

Hi Chris,

First, the array of bytes needs to be passed by reference to SetKeyboardState. Anyway, I just tested the following and it worked fine:
#DEFINE VK_SCROLL 0x92
DECLARE INTEGER GetKeyboardState IN Win32API;
  STRING @lpCodes
DECLARE INTEGER SetKeyboardState IN Win32API;
  STRING @lpCodes
lccodes = SPACE(256)
= GetKeyboardState(@lccodes)
* For Windows 95/98
* Toggle the scroll lock
lccodes = LEFT(lccodes, VK_SCROLL - 1) +;
  CHR(BITXOR(ASC(SUBSTR(lccodes, VK_SCROLL, 1)), 1))+;
  SUBSTR(lccodes, VK_SCROLL + 1)
= SetKeyboardState(@lccodes)

* For Windows NT, however, you have to use the keybd_event function, as follows:

* Simulate key down
= keybd_event(VK_SCROLL, 0x45, KEYEVENTF_EXTENDEDKEY, 0)
* Simulate key up
= keybd_event(VK_SCROLL, 0x45, BITOR(KEYEVENTF_EXTENDEDKEY, KEYEVENTF_KEYUP), 0)
I haven't provided further details since you seem to have access to the SDK. Let me know if you need further details.
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform