Try vbnet. I remember they have a clear example on this issue. You can also
try your luck at newsgroup microsoft.public.vb.winapi. I am afraid the MS
Word newsgroups are not the appropriate fora for your question.
> I need to turn off the CapsLock key under program control. I've looked
> through the archives and found two ways to do it, but neither is
completely
> satisfactory.
> These are the two routines which I've found. There are other things
involved
> like Public Declares, but this is the gist of the working code.
> --------------------------------------------------------------------------
--
> ----
> Private Sub SetKeyState(intKey As Integer, fTurnOn As Boolean)
> ' Retrieve the keyboard state, set the particular
> ' key in which you're interested, and then set
> ' the entire keyboard state back the way it
> ' was, with the one key altered.
> Dim abytBuffer(0 To 255) As Byte
> GetKeyboardState abytBuffer(0)
> abytBuffer(intKey) = CByte(Abs(fTurnOn))
> SetKeyboardState abytBuffer(0)
> End Sub
> --------------------------------------------------------------------------
--
> ----
> Sub SetCapsLockKeyOff()
> If CBool(GetKeyState(vbKeyCapital)) Then
> ' programmatically press and release the CapsLock key
> keybd_event vbKeyCapital, 0, 0, 0
> keybd_event vbKeyCapital, 0, KEYEVENTF_KEYUP, 0
> End If
> End Sub
> --------------------------------------------------------------------------
--
> ----
> The first, SetKeyState works fine, but doesn't affect the CapsLock light
on
> the keyboard, so that the status of the light and the function are at
odds.
> Calling it again puts them back in sync, and if I leave the app altogether
> and start on something else, it eventually links up again.
> The second routine also works fine, and kills the light, but it does so by
> forcing a key event. I call the routine from a Key event in a Word
UserForm,
> which is triggered again by the key force, which calls the Key event
again,
> which... You can see the problem
> Does anyone know of a solution which BOTH turns off the CapsLock AND the
> light, without forcing a key event? It's obviously possible, since Word's
> autocorrect feature does exactly that, but I don't know if it's accessible
> from VBA.
> --
> Pete
> -----------------------------------------------------------
> (This e-mail address is fake, to keep spammers and their auto-harvesters
out
> of my hair. If you want to get in touch personally, I am 'pdanes' and I
use
> yahoo mail. But please use the newsgroup when possible, so that all may
> benefit from the exchange of ideas)