get the array of keycodes for the keys that were pressed


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: get the array of keycodes for the keys that were pressed

Hybrid View

  1. #1
    vasantha Guest

    get the array of keycodes for the keys that were pressed


    Hello,
    Thanks for your response. But, I did look into the PSDK help but was not
    able to find what I was looking for. Here's what I am currently doing:

    In my Form.KeyDown event, I make a call to isStickyKeysOn method and if it
    is on, then I want to know which of the keyboard keys were pressed. For eg:
    if the keyboard keys that were pressed were Alt and 'A' then, I would perform
    the corresponding action for Alt+A. The part I am not sure how to do is to
    - get the array of keycodes for the keys that were pressed.

    I looked into the GetKeyboardState API call. But, using that would require
    me to go through all the 256 characters in the list and find out the ones
    that are on (pressed). Is there any other way of doing this.

    Could yo please point me to the help topic that you have mentioned.
    Your help is much appreciated.
    thanks,
    -Vasantha

    Public Function isStickyKeysOn() As Boolean
    Dim mk As STICKYKEYS
    Dim retval As Long

    mk.cbSize = Len(mk)
    ' Load the MouseKeys settings into the structure.
    retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)

    If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    isStickyKeysOn = True
    Else
    isStickyKeysOn = False
    End If

    End Function


    "
    Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com> wrote:
    >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK help topic

    for
    >the flags to check for....
    >
    >
    >--
    >MichKa
    >
    >Michael Kaplan
    >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >
    >International VB? -- http://www.i18nWithVB.com/
    >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >
    >
    >"Vasantha" <vasantha@us.ibm.com> wrote in message
    >news:3ceef13d@10.1.10.29...
    >>
    >> Hi,
    >>
    >> I am trying to find out what system call I should use in order to be able
    >> to read the array of key strokes that the user entered.
    >> I am using the "SystemParametersInfo" call to find if the stickkeys in

    the
    >> system accessibility settings are set to "ON" or "OFF". I have this part
    >> working.
    >> FYI: sticky keys are turned on in case the user is not able to click on

    >multiple
    >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del, by setting
    >> the sticky keys ON, the user can click on the Ctrl, the Alt and the Del

    >buttons
    >> individually one at a time and accomplish this.
    >>
    >> So, my next task is to read from the system the keys that were entered

    and
    >> then using that information, I can divert control to the various parts

    of
    >> my application. This is the part I am not sure how to do.
    >>
    >> I was told by another colleague that this could be accomplished by making
    >> another call to "SystemParametersInfo" but using different parameter.

    But,
    >> I have not been able to figure this out as yet.
    >>
    >> Any help in this regard would be greatly appreciated.
    >> Thanks for your help in advance.
    >>
    >> -Vasantha
    >>

    >
    >



  2. #2
    Michael \(michka\) Kaplan Guest

    Re: get the array of keycodes for the keys that were pressed

    It is the same API you are already using!!!

    You are currently checking for a single flag -- SKF_STICKYKEYSON. You have
    to check for some of the other flags, thats all.


    --
    MichKa

    Michael Kaplan
    Trigeminal Software, Inc. -- http://www.trigeminal.com/

    International VB? -- http://www.i18nWithVB.com/
    C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/



    "vasantha" <vasantha@us.ibm.com> wrote in message
    news:3cf7fa4d$1@10.1.10.29...
    >
    > Hello,
    > Thanks for your response. But, I did look into the PSDK help but was not
    > able to find what I was looking for. Here's what I am currently doing:
    >
    > In my Form.KeyDown event, I make a call to isStickyKeysOn method and if it
    > is on, then I want to know which of the keyboard keys were pressed. For

    eg:
    > if the keyboard keys that were pressed were Alt and 'A' then, I would

    perform
    > the corresponding action for Alt+A. The part I am not sure how to do is to
    > - get the array of keycodes for the keys that were pressed.
    >
    > I looked into the GetKeyboardState API call. But, using that would require
    > me to go through all the 256 characters in the list and find out the ones
    > that are on (pressed). Is there any other way of doing this.
    >
    > Could yo please point me to the help topic that you have mentioned.
    > Your help is much appreciated.
    > thanks,
    > -Vasantha
    >
    > Public Function isStickyKeysOn() As Boolean
    > Dim mk As STICKYKEYS
    > Dim retval As Long
    >
    > mk.cbSize = Len(mk)
    > ' Load the MouseKeys settings into the structure.
    > retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)
    >
    > If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    > isStickyKeysOn = True
    > Else
    > isStickyKeysOn = False
    > End If
    >
    > End Function
    >
    >
    > "
    > Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    wrote:
    > >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK help topic

    > for
    > >the flags to check for....
    > >
    > >
    > >--
    > >MichKa
    > >
    > >Michael Kaplan
    > >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >
    > >International VB? -- http://www.i18nWithVB.com/
    > >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >
    > >
    > >"Vasantha" <vasantha@us.ibm.com> wrote in message
    > >news:3ceef13d@10.1.10.29...
    > >>
    > >> Hi,
    > >>
    > >> I am trying to find out what system call I should use in order to be

    able
    > >> to read the array of key strokes that the user entered.
    > >> I am using the "SystemParametersInfo" call to find if the stickkeys in

    > the
    > >> system accessibility settings are set to "ON" or "OFF". I have this

    part
    > >> working.
    > >> FYI: sticky keys are turned on in case the user is not able to click on

    > >multiple
    > >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del, by

    setting
    > >> the sticky keys ON, the user can click on the Ctrl, the Alt and the Del

    > >buttons
    > >> individually one at a time and accomplish this.
    > >>
    > >> So, my next task is to read from the system the keys that were entered

    > and
    > >> then using that information, I can divert control to the various parts

    > of
    > >> my application. This is the part I am not sure how to do.
    > >>
    > >> I was told by another colleague that this could be accomplished by

    making
    > >> another call to "SystemParametersInfo" but using different parameter.

    > But,
    > >> I have not been able to figure this out as yet.
    > >>
    > >> Any help in this regard would be greatly appreciated.
    > >> Thanks for your help in advance.
    > >>
    > >> -Vasantha
    > >>

    > >
    > >

    >




  3. #3
    vasantha Guest

    Re: get the array of keycodes for the keys that were pressed


    Thanks for pointing it out to me. I needed to program the shortcut keys so
    I am now checking for the additional flags such as SKF_LALTLATCHED(Right
    Alt Key press) and SKF_RALTLATCHED (left Alt Key press).

    The PSDK help indicates that SKF_LALTLATCHED and SKF_RALTLATCHED are supported
    in Windows 98 and 2000.
    http://msdn.microsoft.com/library/de...ccess_1alu.asp

    I have tried my test case on Windows NT as well as Windows 2000 and I have
    not been able to successfully use it. I do a bit wise AND on the dwFlags
    (that I receive from the sticky keys strcture) and the constant SKF_LALTLATCHED.
    This always returns a value of 0. My understanding is that it should return
    a value of 1 if it is 'ON' and a value of '0' if it is 'OFF'. Is this approach
    correct?

    Also, if possible could you please point me to any such sample code snippets
    that you might have come across.

    Thanks a lot for your help.

    -Vasantha


    my code follows:
    'Constants values are as declared in Winuser.h file
    Public Const SKF_LALTLATCHED = &H10000000
    Public Const SKF_RALTLATCHED = &H20000000

    Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    Dim mk As STICKYKEYS ' holds settings for StickyKeys
    Dim retval As Long ' return value

    mk.cbSize = Len(mk) ' set the size of the structure
    retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0) ' don't
    need to notify

    If (mk.dwFlags And SKF_STICKYKEYSON) Then
    Debug.Print "STICKY KEY is on."

    If (mk.dwFlags And SKF_LALTLATCHED) Then
    Debug.Print "Left Alt key is latched "
    isStickyKeysOnAndALTKeyLatched = True
    End If

    If (mk.dwFlags And SKF_RALTLATCHED) Then
    Debug.Print "Right Alt key is latched "
    isStickyKeysOnAndALTKeyLatched = True
    End If

    Else
    Debug.Print "STICKY KEY is OFF."
    isStickyKeysOnAndALTKeyLatched = False
    End If

    End Function



    "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com> wrote:
    >It is the same API you are already using!!!
    >
    >You are currently checking for a single flag -- SKF_STICKYKEYSON. You have
    >to check for some of the other flags, thats all.
    >
    >
    >--
    >MichKa
    >
    >Michael Kaplan
    >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >
    >International VB? -- http://www.i18nWithVB.com/
    >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >
    >
    >
    >"vasantha" <vasantha@us.ibm.com> wrote in message
    >news:3cf7fa4d$1@10.1.10.29...
    >>
    >> Hello,
    >> Thanks for your response. But, I did look into the PSDK help but was not
    >> able to find what I was looking for. Here's what I am currently doing:
    >>
    >> In my Form.KeyDown event, I make a call to isStickyKeysOn method and if

    it
    >> is on, then I want to know which of the keyboard keys were pressed. For

    >eg:
    >> if the keyboard keys that were pressed were Alt and 'A' then, I would

    >perform
    >> the corresponding action for Alt+A. The part I am not sure how to do is

    to
    >> - get the array of keycodes for the keys that were pressed.
    >>
    >> I looked into the GetKeyboardState API call. But, using that would require
    >> me to go through all the 256 characters in the list and find out the ones
    >> that are on (pressed). Is there any other way of doing this.
    >>
    >> Could yo please point me to the help topic that you have mentioned.
    >> Your help is much appreciated.
    >> thanks,
    >> -Vasantha
    >>
    >> Public Function isStickyKeysOn() As Boolean
    >> Dim mk As STICKYKEYS
    >> Dim retval As Long
    >>
    >> mk.cbSize = Len(mk)
    >> ' Load the MouseKeys settings into the structure.
    >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)
    >>
    >> If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    >> isStickyKeysOn = True
    >> Else
    >> isStickyKeysOn = False
    >> End If
    >>
    >> End Function
    >>
    >>
    >> "
    >> Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    >wrote:
    >> >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK help topic

    >> for
    >> >the flags to check for....
    >> >
    >> >
    >> >--
    >> >MichKa
    >> >
    >> >Michael Kaplan
    >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >
    >> >International VB? -- http://www.i18nWithVB.com/
    >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >
    >> >
    >> >"Vasantha" <vasantha@us.ibm.com> wrote in message
    >> >news:3ceef13d@10.1.10.29...
    >> >>
    >> >> Hi,
    >> >>
    >> >> I am trying to find out what system call I should use in order to be

    >able
    >> >> to read the array of key strokes that the user entered.
    >> >> I am using the "SystemParametersInfo" call to find if the stickkeys

    in
    >> the
    >> >> system accessibility settings are set to "ON" or "OFF". I have this

    >part
    >> >> working.
    >> >> FYI: sticky keys are turned on in case the user is not able to click

    on
    >> >multiple
    >> >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del, by

    >setting
    >> >> the sticky keys ON, the user can click on the Ctrl, the Alt and the

    Del
    >> >buttons
    >> >> individually one at a time and accomplish this.
    >> >>
    >> >> So, my next task is to read from the system the keys that were entered

    >> and
    >> >> then using that information, I can divert control to the various parts

    >> of
    >> >> my application. This is the part I am not sure how to do.
    >> >>
    >> >> I was told by another colleague that this could be accomplished by

    >making
    >> >> another call to "SystemParametersInfo" but using different parameter.

    >> But,
    >> >> I have not been able to figure this out as yet.
    >> >>
    >> >> Any help in this regard would be greatly appreciated.
    >> >> Thanks for your help in advance.
    >> >>
    >> >> -Vasantha
    >> >>
    >> >
    >> >

    >>

    >
    >



  4. #4
    Michael \(michka\) Kaplan Guest

    Re: get the array of keycodes for the keys that were pressed

    What is the exact numeric value of dwFlags and what is the current state of
    the sticky keys when that number is what is there?


    --
    MichKa

    Michael Kaplan
    Trigeminal Software, Inc. -- http://www.trigeminal.com/

    International VB? -- http://www.i18nWithVB.com/
    C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/


    "vasantha" <vb.@127.0.0.1> wrote in message news:3cfcf74a$1@10.1.10.29...
    >
    > Thanks for pointing it out to me. I needed to program the shortcut keys so
    > I am now checking for the additional flags such as SKF_LALTLATCHED(Right
    > Alt Key press) and SKF_RALTLATCHED (left Alt Key press).
    >
    > The PSDK help indicates that SKF_LALTLATCHED and SKF_RALTLATCHED are

    supported
    > in Windows 98 and 2000.
    >

    http://msdn.microsoft.com/library/de...us/msaa/access
    _1alu.asp
    >
    > I have tried my test case on Windows NT as well as Windows 2000 and I have
    > not been able to successfully use it. I do a bit wise AND on the dwFlags
    > (that I receive from the sticky keys strcture) and the constant

    SKF_LALTLATCHED.
    > This always returns a value of 0. My understanding is that it should

    return
    > a value of 1 if it is 'ON' and a value of '0' if it is 'OFF'. Is this

    approach
    > correct?
    >
    > Also, if possible could you please point me to any such sample code

    snippets
    > that you might have come across.
    >
    > Thanks a lot for your help.
    >
    > -Vasantha
    >
    >
    > my code follows:
    > 'Constants values are as declared in Winuser.h file
    > Public Const SKF_LALTLATCHED = &H10000000
    > Public Const SKF_RALTLATCHED = &H20000000
    >
    > Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    > Dim mk As STICKYKEYS ' holds settings for StickyKeys
    > Dim retval As Long ' return value
    >
    > mk.cbSize = Len(mk) ' set the size of the structure
    > retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0) '

    don't
    > need to notify
    >
    > If (mk.dwFlags And SKF_STICKYKEYSON) Then
    > Debug.Print "STICKY KEY is on."
    >
    > If (mk.dwFlags And SKF_LALTLATCHED) Then
    > Debug.Print "Left Alt key is latched "
    > isStickyKeysOnAndALTKeyLatched = True
    > End If
    >
    > If (mk.dwFlags And SKF_RALTLATCHED) Then
    > Debug.Print "Right Alt key is latched "
    > isStickyKeysOnAndALTKeyLatched = True
    > End If
    >
    > Else
    > Debug.Print "STICKY KEY is OFF."
    > isStickyKeysOnAndALTKeyLatched = False
    > End If
    >
    > End Function
    >
    >
    >
    > "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    wrote:
    > >It is the same API you are already using!!!
    > >
    > >You are currently checking for a single flag -- SKF_STICKYKEYSON. You

    have
    > >to check for some of the other flags, thats all.
    > >
    > >
    > >--
    > >MichKa
    > >
    > >Michael Kaplan
    > >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >
    > >International VB? -- http://www.i18nWithVB.com/
    > >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >
    > >
    > >
    > >"vasantha" <vasantha@us.ibm.com> wrote in message
    > >news:3cf7fa4d$1@10.1.10.29...
    > >>
    > >> Hello,
    > >> Thanks for your response. But, I did look into the PSDK help but was

    not
    > >> able to find what I was looking for. Here's what I am currently doing:
    > >>
    > >> In my Form.KeyDown event, I make a call to isStickyKeysOn method and if

    > it
    > >> is on, then I want to know which of the keyboard keys were pressed. For

    > >eg:
    > >> if the keyboard keys that were pressed were Alt and 'A' then, I would

    > >perform
    > >> the corresponding action for Alt+A. The part I am not sure how to do is

    > to
    > >> - get the array of keycodes for the keys that were pressed.
    > >>
    > >> I looked into the GetKeyboardState API call. But, using that would

    require
    > >> me to go through all the 256 characters in the list and find out the

    ones
    > >> that are on (pressed). Is there any other way of doing this.
    > >>
    > >> Could yo please point me to the help topic that you have mentioned.
    > >> Your help is much appreciated.
    > >> thanks,
    > >> -Vasantha
    > >>
    > >> Public Function isStickyKeysOn() As Boolean
    > >> Dim mk As STICKYKEYS
    > >> Dim retval As Long
    > >>
    > >> mk.cbSize = Len(mk)
    > >> ' Load the MouseKeys settings into the structure.
    > >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)
    > >>
    > >> If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    > >> isStickyKeysOn = True
    > >> Else
    > >> isStickyKeysOn = False
    > >> End If
    > >>
    > >> End Function
    > >>
    > >>
    > >> "
    > >> Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    > >wrote:
    > >> >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK help

    topic
    > >> for
    > >> >the flags to check for....
    > >> >
    > >> >
    > >> >--
    > >> >MichKa
    > >> >
    > >> >Michael Kaplan
    > >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >> >
    > >> >International VB? -- http://www.i18nWithVB.com/
    > >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >> >
    > >> >
    > >> >"Vasantha" <vasantha@us.ibm.com> wrote in message
    > >> >news:3ceef13d@10.1.10.29...
    > >> >>
    > >> >> Hi,
    > >> >>
    > >> >> I am trying to find out what system call I should use in order to be

    > >able
    > >> >> to read the array of key strokes that the user entered.
    > >> >> I am using the "SystemParametersInfo" call to find if the stickkeys

    > in
    > >> the
    > >> >> system accessibility settings are set to "ON" or "OFF". I have this

    > >part
    > >> >> working.
    > >> >> FYI: sticky keys are turned on in case the user is not able to click

    > on
    > >> >multiple
    > >> >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del, by

    > >setting
    > >> >> the sticky keys ON, the user can click on the Ctrl, the Alt and the

    > Del
    > >> >buttons
    > >> >> individually one at a time and accomplish this.
    > >> >>
    > >> >> So, my next task is to read from the system the keys that were

    entered
    > >> and
    > >> >> then using that information, I can divert control to the various

    parts
    > >> of
    > >> >> my application. This is the part I am not sure how to do.
    > >> >>
    > >> >> I was told by another colleague that this could be accomplished by

    > >making
    > >> >> another call to "SystemParametersInfo" but using different

    parameter.
    > >> But,
    > >> >> I have not been able to figure this out as yet.
    > >> >>
    > >> >> Any help in this regard would be greatly appreciated.
    > >> >> Thanks for your help in advance.
    > >> >>
    > >> >> -Vasantha
    > >> >>
    > >> >
    > >> >
    > >>

    > >
    > >

    >




  5. #5
    Vasantha Guest

    Re: get the array of keycodes for the keys that were pressed


    The current state of the sticky keys is 'ON' and the value of dwFlags is 475
    (when tested on WinNT) and 255 (when tested on Windows 2000). These are the
    values I see when debugging the code when I press the ALT key.
    Thanks a lot for your response. I really appreciate all your help.

    -Vasantha

    "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com> wrote:
    >What is the exact numeric value of dwFlags and what is the current state

    of
    >the sticky keys when that number is what is there?
    >
    >
    >--
    >MichKa
    >
    >Michael Kaplan
    >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >
    >International VB? -- http://www.i18nWithVB.com/
    >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >
    >
    >"vasantha" <vb.@127.0.0.1> wrote in message news:3cfcf74a$1@10.1.10.29...
    >>
    >> Thanks for pointing it out to me. I needed to program the shortcut keys

    so
    >> I am now checking for the additional flags such as SKF_LALTLATCHED(Right
    >> Alt Key press) and SKF_RALTLATCHED (left Alt Key press).
    >>
    >> The PSDK help indicates that SKF_LALTLATCHED and SKF_RALTLATCHED are

    >supported
    >> in Windows 98 and 2000.
    >>

    >http://msdn.microsoft.com/library/de...us/msaa/access
    >_1alu.asp
    >>
    >> I have tried my test case on Windows NT as well as Windows 2000 and I

    have
    >> not been able to successfully use it. I do a bit wise AND on the dwFlags
    >> (that I receive from the sticky keys strcture) and the constant

    >SKF_LALTLATCHED.
    >> This always returns a value of 0. My understanding is that it should

    >return
    >> a value of 1 if it is 'ON' and a value of '0' if it is 'OFF'. Is this

    >approach
    >> correct?
    >>
    >> Also, if possible could you please point me to any such sample code

    >snippets
    >> that you might have come across.
    >>
    >> Thanks a lot for your help.
    >>
    >> -Vasantha
    >>
    >>
    >> my code follows:
    >> 'Constants values are as declared in Winuser.h file
    >> Public Const SKF_LALTLATCHED = &H10000000
    >> Public Const SKF_RALTLATCHED = &H20000000
    >>
    >> Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    >> Dim mk As STICKYKEYS ' holds settings for StickyKeys
    >> Dim retval As Long ' return value
    >>
    >> mk.cbSize = Len(mk) ' set the size of the structure
    >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)

    '
    >don't
    >> need to notify
    >>
    >> If (mk.dwFlags And SKF_STICKYKEYSON) Then
    >> Debug.Print "STICKY KEY is on."
    >>
    >> If (mk.dwFlags And SKF_LALTLATCHED) Then
    >> Debug.Print "Left Alt key is latched "
    >> isStickyKeysOnAndALTKeyLatched = True
    >> End If
    >>
    >> If (mk.dwFlags And SKF_RALTLATCHED) Then
    >> Debug.Print "Right Alt key is latched "
    >> isStickyKeysOnAndALTKeyLatched = True
    >> End If
    >>
    >> Else
    >> Debug.Print "STICKY KEY is OFF."
    >> isStickyKeysOnAndALTKeyLatched = False
    >> End If
    >>
    >> End Function
    >>
    >>
    >>
    >> "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    >wrote:
    >> >It is the same API you are already using!!!
    >> >
    >> >You are currently checking for a single flag -- SKF_STICKYKEYSON. You

    >have
    >> >to check for some of the other flags, thats all.
    >> >
    >> >
    >> >--
    >> >MichKa
    >> >
    >> >Michael Kaplan
    >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >
    >> >International VB? -- http://www.i18nWithVB.com/
    >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >
    >> >
    >> >
    >> >"vasantha" <vasantha@us.ibm.com> wrote in message
    >> >news:3cf7fa4d$1@10.1.10.29...
    >> >>
    >> >> Hello,
    >> >> Thanks for your response. But, I did look into the PSDK help but was

    >not
    >> >> able to find what I was looking for. Here's what I am currently doing:
    >> >>
    >> >> In my Form.KeyDown event, I make a call to isStickyKeysOn method and

    if
    >> it
    >> >> is on, then I want to know which of the keyboard keys were pressed.

    For
    >> >eg:
    >> >> if the keyboard keys that were pressed were Alt and 'A' then, I would
    >> >perform
    >> >> the corresponding action for Alt+A. The part I am not sure how to do

    is
    >> to
    >> >> - get the array of keycodes for the keys that were pressed.
    >> >>
    >> >> I looked into the GetKeyboardState API call. But, using that would

    >require
    >> >> me to go through all the 256 characters in the list and find out the

    >ones
    >> >> that are on (pressed). Is there any other way of doing this.
    >> >>
    >> >> Could yo please point me to the help topic that you have mentioned.
    >> >> Your help is much appreciated.
    >> >> thanks,
    >> >> -Vasantha
    >> >>
    >> >> Public Function isStickyKeysOn() As Boolean
    >> >> Dim mk As STICKYKEYS
    >> >> Dim retval As Long
    >> >>
    >> >> mk.cbSize = Len(mk)
    >> >> ' Load the MouseKeys settings into the structure.
    >> >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)
    >> >>
    >> >> If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    >> >> isStickyKeysOn = True
    >> >> Else
    >> >> isStickyKeysOn = False
    >> >> End If
    >> >>
    >> >> End Function
    >> >>
    >> >>
    >> >> "
    >> >> Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>
    >> >wrote:
    >> >> >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK help

    >topic
    >> >> for
    >> >> >the flags to check for....
    >> >> >
    >> >> >
    >> >> >--
    >> >> >MichKa
    >> >> >
    >> >> >Michael Kaplan
    >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >> >
    >> >> >International VB? -- http://www.i18nWithVB.com/
    >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >> >
    >> >> >
    >> >> >"Vasantha" <vasantha@us.ibm.com> wrote in message
    >> >> >news:3ceef13d@10.1.10.29...
    >> >> >>
    >> >> >> Hi,
    >> >> >>
    >> >> >> I am trying to find out what system call I should use in order to

    be
    >> >able
    >> >> >> to read the array of key strokes that the user entered.
    >> >> >> I am using the "SystemParametersInfo" call to find if the stickkeys

    >> in
    >> >> the
    >> >> >> system accessibility settings are set to "ON" or "OFF". I have this
    >> >part
    >> >> >> working.
    >> >> >> FYI: sticky keys are turned on in case the user is not able to click

    >> on
    >> >> >multiple
    >> >> >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del, by
    >> >setting
    >> >> >> the sticky keys ON, the user can click on the Ctrl, the Alt and

    the
    >> Del
    >> >> >buttons
    >> >> >> individually one at a time and accomplish this.
    >> >> >>
    >> >> >> So, my next task is to read from the system the keys that were

    >entered
    >> >> and
    >> >> >> then using that information, I can divert control to the various

    >parts
    >> >> of
    >> >> >> my application. This is the part I am not sure how to do.
    >> >> >>
    >> >> >> I was told by another colleague that this could be accomplished

    by
    >> >making
    >> >> >> another call to "SystemParametersInfo" but using different

    >parameter.
    >> >> But,
    >> >> >> I have not been able to figure this out as yet.
    >> >> >>
    >> >> >> Any help in this regard would be greatly appreciated.
    >> >> >> Thanks for your help in advance.
    >> >> >>
    >> >> >> -Vasantha
    >> >> >>
    >> >> >
    >> >> >
    >> >>
    >> >
    >> >

    >>

    >
    >



  6. #6
    Michael \(michka\) Kaplan Guest

    Re: get the array of keycodes for the keys that were pressed

    I do not know what your declarations are for the type or the API, I suspect
    they are flawed. A few items:

    1) Use the HEX form of the dwFlags value so you can compare them to the
    constants

    2) Stop trying to use NT4, it is not supported there

    3) Post your declarations, etc.


    --
    MichKa

    Michael Kaplan
    Trigeminal Software, Inc. -- http://www.trigeminal.com/

    International VB? -- http://www.i18nWithVB.com/
    C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/


    "Vasantha" <vb.@127.0.0.1> wrote in message news:3cffab99$1@10.1.10.29...
    >
    > The current state of the sticky keys is 'ON' and the value of dwFlags is

    475
    > (when tested on WinNT) and 255 (when tested on Windows 2000). These are

    the
    > values I see when debugging the code when I press the ALT key.
    > Thanks a lot for your response. I really appreciate all your help.
    >
    > -Vasantha
    >
    > "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    wrote:
    > >What is the exact numeric value of dwFlags and what is the current state

    > of
    > >the sticky keys when that number is what is there?
    > >
    > >
    > >--
    > >MichKa
    > >
    > >Michael Kaplan
    > >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >
    > >International VB? -- http://www.i18nWithVB.com/
    > >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >
    > >
    > >"vasantha" <vb.@127.0.0.1> wrote in message news:3cfcf74a$1@10.1.10.29...
    > >>
    > >> Thanks for pointing it out to me. I needed to program the shortcut keys

    > so
    > >> I am now checking for the additional flags such as

    SKF_LALTLATCHED(Right
    > >> Alt Key press) and SKF_RALTLATCHED (left Alt Key press).
    > >>
    > >> The PSDK help indicates that SKF_LALTLATCHED and SKF_RALTLATCHED are

    > >supported
    > >> in Windows 98 and 2000.
    > >>

    >
    >http://msdn.microsoft.com/library/de...-us/msaa/acces

    s
    > >_1alu.asp
    > >>
    > >> I have tried my test case on Windows NT as well as Windows 2000 and I

    > have
    > >> not been able to successfully use it. I do a bit wise AND on the

    dwFlags
    > >> (that I receive from the sticky keys strcture) and the constant

    > >SKF_LALTLATCHED.
    > >> This always returns a value of 0. My understanding is that it should

    > >return
    > >> a value of 1 if it is 'ON' and a value of '0' if it is 'OFF'. Is this

    > >approach
    > >> correct?
    > >>
    > >> Also, if possible could you please point me to any such sample code

    > >snippets
    > >> that you might have come across.
    > >>
    > >> Thanks a lot for your help.
    > >>
    > >> -Vasantha
    > >>
    > >>
    > >> my code follows:
    > >> 'Constants values are as declared in Winuser.h file
    > >> Public Const SKF_LALTLATCHED = &H10000000
    > >> Public Const SKF_RALTLATCHED = &H20000000
    > >>
    > >> Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    > >> Dim mk As STICKYKEYS ' holds settings for StickyKeys
    > >> Dim retval As Long ' return value
    > >>
    > >> mk.cbSize = Len(mk) ' set the size of the structure
    > >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)

    > '
    > >don't
    > >> need to notify
    > >>
    > >> If (mk.dwFlags And SKF_STICKYKEYSON) Then
    > >> Debug.Print "STICKY KEY is on."
    > >>
    > >> If (mk.dwFlags And SKF_LALTLATCHED) Then
    > >> Debug.Print "Left Alt key is latched "
    > >> isStickyKeysOnAndALTKeyLatched = True
    > >> End If
    > >>
    > >> If (mk.dwFlags And SKF_RALTLATCHED) Then
    > >> Debug.Print "Right Alt key is latched "
    > >> isStickyKeysOnAndALTKeyLatched = True
    > >> End If
    > >>
    > >> Else
    > >> Debug.Print "STICKY KEY is OFF."
    > >> isStickyKeysOnAndALTKeyLatched = False
    > >> End If
    > >>
    > >> End Function
    > >>
    > >>
    > >>
    > >> "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    > >wrote:
    > >> >It is the same API you are already using!!!
    > >> >
    > >> >You are currently checking for a single flag -- SKF_STICKYKEYSON. You

    > >have
    > >> >to check for some of the other flags, thats all.
    > >> >
    > >> >
    > >> >--
    > >> >MichKa
    > >> >
    > >> >Michael Kaplan
    > >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >> >
    > >> >International VB? -- http://www.i18nWithVB.com/
    > >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >> >
    > >> >
    > >> >
    > >> >"vasantha" <vasantha@us.ibm.com> wrote in message
    > >> >news:3cf7fa4d$1@10.1.10.29...
    > >> >>
    > >> >> Hello,
    > >> >> Thanks for your response. But, I did look into the PSDK help but was

    > >not
    > >> >> able to find what I was looking for. Here's what I am currently

    doing:
    > >> >>
    > >> >> In my Form.KeyDown event, I make a call to isStickyKeysOn method and

    > if
    > >> it
    > >> >> is on, then I want to know which of the keyboard keys were pressed.

    > For
    > >> >eg:
    > >> >> if the keyboard keys that were pressed were Alt and 'A' then, I

    would
    > >> >perform
    > >> >> the corresponding action for Alt+A. The part I am not sure how to do

    > is
    > >> to
    > >> >> - get the array of keycodes for the keys that were pressed.
    > >> >>
    > >> >> I looked into the GetKeyboardState API call. But, using that would

    > >require
    > >> >> me to go through all the 256 characters in the list and find out the

    > >ones
    > >> >> that are on (pressed). Is there any other way of doing this.
    > >> >>
    > >> >> Could yo please point me to the help topic that you have mentioned.
    > >> >> Your help is much appreciated.
    > >> >> thanks,
    > >> >> -Vasantha
    > >> >>
    > >> >> Public Function isStickyKeysOn() As Boolean
    > >> >> Dim mk As STICKYKEYS
    > >> >> Dim retval As Long
    > >> >>
    > >> >> mk.cbSize = Len(mk)
    > >> >> ' Load the MouseKeys settings into the structure.
    > >> >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)
    > >> >>
    > >> >> If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    > >> >> isStickyKeysOn = True
    > >> >> Else
    > >> >> isStickyKeysOn = False
    > >> >> End If
    > >> >>
    > >> >> End Function
    > >> >>
    > >> >>
    > >> >> "
    > >> >> Michael \(michka\) Kaplan"

    <former_mvp@nospam.trigeminal.spamless.com>
    > >> >wrote:
    > >> >> >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK help

    > >topic
    > >> >> for
    > >> >> >the flags to check for....
    > >> >> >
    > >> >> >
    > >> >> >--
    > >> >> >MichKa
    > >> >> >
    > >> >> >Michael Kaplan
    > >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >> >> >
    > >> >> >International VB? -- http://www.i18nWithVB.com/
    > >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >> >> >
    > >> >> >
    > >> >> >"Vasantha" <vasantha@us.ibm.com> wrote in message
    > >> >> >news:3ceef13d@10.1.10.29...
    > >> >> >>
    > >> >> >> Hi,
    > >> >> >>
    > >> >> >> I am trying to find out what system call I should use in order to

    > be
    > >> >able
    > >> >> >> to read the array of key strokes that the user entered.
    > >> >> >> I am using the "SystemParametersInfo" call to find if the

    stickkeys
    > >> in
    > >> >> the
    > >> >> >> system accessibility settings are set to "ON" or "OFF". I have

    this
    > >> >part
    > >> >> >> working.
    > >> >> >> FYI: sticky keys are turned on in case the user is not able to

    click
    > >> on
    > >> >> >multiple
    > >> >> >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del, by
    > >> >setting
    > >> >> >> the sticky keys ON, the user can click on the Ctrl, the Alt and

    > the
    > >> Del
    > >> >> >buttons
    > >> >> >> individually one at a time and accomplish this.
    > >> >> >>
    > >> >> >> So, my next task is to read from the system the keys that were

    > >entered
    > >> >> and
    > >> >> >> then using that information, I can divert control to the various

    > >parts
    > >> >> of
    > >> >> >> my application. This is the part I am not sure how to do.
    > >> >> >>
    > >> >> >> I was told by another colleague that this could be accomplished

    > by
    > >> >making
    > >> >> >> another call to "SystemParametersInfo" but using different

    > >parameter.
    > >> >> But,
    > >> >> >> I have not been able to figure this out as yet.
    > >> >> >>
    > >> >> >> Any help in this regard would be greatly appreciated.
    > >> >> >> Thanks for your help in advance.
    > >> >> >>
    > >> >> >> -Vasantha
    > >> >> >>
    > >> >> >
    > >> >> >
    > >> >>
    > >> >
    > >> >
    > >>

    > >
    > >

    >




  7. #7
    Vasantha Guest

    Re: get the array of keycodes for the keys that were pressed


    Thanks. Here are my declarations and I have also included the part of the
    winuser.h file from where I copied the constant values for the dwFlags.
    And, ok I will stop testing on NT since it is not supported there.

    >1) Use the HEX form of the dwFlags value so you can compare them to the
    >constants


    Are you suggesting that I directly compare the dwFlags value to that of the
    constants? I was under the understanding that each of these flags were represented
    by a certain bit in the value of the dwFlags and the value of the dwFlags
    itself is not of much use. Is this correct or have I misunderstood your suggestion?

    my code follows:
    -----------------------------------------------------------
    'STICKY KEYS implementation
    Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA"
    (ByVal uAction As Long, ByVal uiParam As Long, pvParam As Any, ByVal fWinIni
    As Long) As Long

    Type STICKYKEYS
    cbSize As Long
    dwFlags As Long
    End Type

    Public Const SKF_AUDIBLEFEEDBACK = &H40
    Public Const SKF_AVAILABLE = &H2
    Public Const SKF_CONFIRMHOTKEY = &H8
    Public Const SKF_HOTKEYACTIVE = &H4
    Public Const SKF_HOTKEYSOUND = &H10
    Public Const SKF_INDICATOR = &H20
    Public Const SKF_STICKYKEYSON = &H1
    Public Const SKF_TRISTATE = &H80
    Public Const SKF_TWOKEYSOFF = &H100
    Public Const SPI_GETSTICKYKEYS = 58

    Public Const SKF_LALTLATCHED = &H10000000
    Public Const SKF_RALTLATCHED = &H20000000
    Public Const SKF_LALTLOCKED = &H100000
    Public Const SKF_RALTLOCKED = &H200000
    Public Const SKF_LSHIFTLATCHED = &H1000000
    Public Const SKF_RSHIFTLATCHED = &H2000000

    Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    Dim mk As STICKYKEYS ' holds settings for StickyKeys
    Dim retval As Long ' return value

    mk.cbSize = Len(mk) ' set the size of the structure
    retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0) ' don't
    need to notify

    If (mk.dwFlags And SKF_STICKYKEYSON) Then
    Debug.Print "STICKY KEY is on."

    If (mk.dwFlags And SKF_LALTLATCHED) Then
    Debug.Print "Left Alt key is latched "
    isStickyKeysOnAndALTKeyLatched = True
    End If

    If (mk.dwFlags And SKF_RALTLATCHED) Then
    Debug.Print "Right Alt key is latched "
    isStickyKeysOnAndALTKeyLatched = True
    End If

    Else
    Debug.Print "STICKY KEY is OFF."
    isStickyKeysOnAndALTKeyLatched = False
    End If

    End Function

    ---------------------------------------------------------------------------
    Here's part of the winuser.h file from where I copied the constant values.

    typedef struct tagSTICKYKEYS
    {
    UINT cbSize;
    DWORD dwFlags;
    } STICKYKEYS, *LPSTICKYKEYS;

    /*
    * STICKYKEYS dwFlags field
    */
    #define SKF_STICKYKEYSON 0x00000001
    #define SKF_AVAILABLE 0x00000002
    #define SKF_HOTKEYACTIVE 0x00000004
    #define SKF_CONFIRMHOTKEY 0x00000008
    #define SKF_HOTKEYSOUND 0x00000010
    #define SKF_INDICATOR 0x00000020
    #define SKF_AUDIBLEFEEDBACK 0x00000040
    #define SKF_TRISTATE 0x00000080
    #define SKF_TWOKEYSOFF 0x00000100
    #if(_WIN32_WINNT >= 0x0500)
    #define SKF_LALTLATCHED 0x10000000
    #define SKF_LCTLLATCHED 0x04000000
    #define SKF_LSHIFTLATCHED 0x01000000
    #define SKF_RALTLATCHED 0x20000000
    #define SKF_RCTLLATCHED 0x08000000
    #define SKF_RSHIFTLATCHED 0x02000000
    #define SKF_LWINLATCHED 0x40000000
    #define SKF_RWINLATCHED 0x80000000
    #define SKF_LALTLOCKED 0x00100000
    #define SKF_LCTLLOCKED 0x00040000
    #define SKF_LSHIFTLOCKED 0x00010000
    #define SKF_RALTLOCKED 0x00200000
    #define SKF_RCTLLOCKED 0x00080000
    #define SKF_RSHIFTLOCKED 0x00020000
    #define SKF_LWINLOCKED 0x00400000
    #define SKF_RWINLOCKED 0x00800000
    #endif /* _WIN32_WINNT >= 0x0500 */

    -------------------------------------------------------------------------

    Thanks for your help.

    -Vasantha


    "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com> wrote:
    >I do not know what your declarations are for the type or the API, I suspect
    >they are flawed. A few items:
    >
    >1) Use the HEX form of the dwFlags value so you can compare them to the
    >constants
    >
    >2) Stop trying to use NT4, it is not supported there
    >
    >3) Post your declarations, etc.
    >
    >
    >--
    >MichKa
    >
    >Michael Kaplan
    >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >
    >International VB? -- http://www.i18nWithVB.com/
    >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >
    >
    >"Vasantha" <vb.@127.0.0.1> wrote in message news:3cffab99$1@10.1.10.29...
    >>
    >> The current state of the sticky keys is 'ON' and the value of dwFlags

    is
    >475
    >> (when tested on WinNT) and 255 (when tested on Windows 2000). These are

    >the
    >> values I see when debugging the code when I press the ALT key.
    >> Thanks a lot for your response. I really appreciate all your help.
    >>
    >> -Vasantha
    >>
    >> "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    >wrote:
    >> >What is the exact numeric value of dwFlags and what is the current state

    >> of
    >> >the sticky keys when that number is what is there?
    >> >
    >> >
    >> >--
    >> >MichKa
    >> >
    >> >Michael Kaplan
    >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >
    >> >International VB? -- http://www.i18nWithVB.com/
    >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >
    >> >
    >> >"vasantha" <vb.@127.0.0.1> wrote in message news:3cfcf74a$1@10.1.10.29...
    >> >>
    >> >> Thanks for pointing it out to me. I needed to program the shortcut

    keys
    >> so
    >> >> I am now checking for the additional flags such as

    >SKF_LALTLATCHED(Right
    >> >> Alt Key press) and SKF_RALTLATCHED (left Alt Key press).
    >> >>
    >> >> The PSDK help indicates that SKF_LALTLATCHED and SKF_RALTLATCHED are
    >> >supported
    >> >> in Windows 98 and 2000.
    >> >>

    >>
    >>http://msdn.microsoft.com/library/de...-us/msaa/acces

    >s
    >> >_1alu.asp
    >> >>
    >> >> I have tried my test case on Windows NT as well as Windows 2000 and

    I
    >> have
    >> >> not been able to successfully use it. I do a bit wise AND on the

    >dwFlags
    >> >> (that I receive from the sticky keys strcture) and the constant
    >> >SKF_LALTLATCHED.
    >> >> This always returns a value of 0. My understanding is that it should
    >> >return
    >> >> a value of 1 if it is 'ON' and a value of '0' if it is 'OFF'. Is this
    >> >approach
    >> >> correct?
    >> >>
    >> >> Also, if possible could you please point me to any such sample code
    >> >snippets
    >> >> that you might have come across.
    >> >>
    >> >> Thanks a lot for your help.
    >> >>
    >> >> -Vasantha
    >> >>
    >> >>
    >> >> my code follows:
    >> >> 'Constants values are as declared in Winuser.h file
    >> >> Public Const SKF_LALTLATCHED = &H10000000
    >> >> Public Const SKF_RALTLATCHED = &H20000000
    >> >>
    >> >> Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    >> >> Dim mk As STICKYKEYS ' holds settings for StickyKeys
    >> >> Dim retval As Long ' return value
    >> >>
    >> >> mk.cbSize = Len(mk) ' set the size of the structure
    >> >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)

    >> '
    >> >don't
    >> >> need to notify
    >> >>
    >> >> If (mk.dwFlags And SKF_STICKYKEYSON) Then
    >> >> Debug.Print "STICKY KEY is on."
    >> >>
    >> >> If (mk.dwFlags And SKF_LALTLATCHED) Then
    >> >> Debug.Print "Left Alt key is latched "
    >> >> isStickyKeysOnAndALTKeyLatched = True
    >> >> End If
    >> >>
    >> >> If (mk.dwFlags And SKF_RALTLATCHED) Then
    >> >> Debug.Print "Right Alt key is latched "
    >> >> isStickyKeysOnAndALTKeyLatched = True
    >> >> End If
    >> >>
    >> >> Else
    >> >> Debug.Print "STICKY KEY is OFF."
    >> >> isStickyKeysOnAndALTKeyLatched = False
    >> >> End If
    >> >>
    >> >> End Function
    >> >>
    >> >>
    >> >>
    >> >> "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>
    >> >wrote:
    >> >> >It is the same API you are already using!!!
    >> >> >
    >> >> >You are currently checking for a single flag -- SKF_STICKYKEYSON.

    You
    >> >have
    >> >> >to check for some of the other flags, thats all.
    >> >> >
    >> >> >
    >> >> >--
    >> >> >MichKa
    >> >> >
    >> >> >Michael Kaplan
    >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >> >
    >> >> >International VB? -- http://www.i18nWithVB.com/
    >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >> >
    >> >> >
    >> >> >
    >> >> >"vasantha" <vasantha@us.ibm.com> wrote in message
    >> >> >news:3cf7fa4d$1@10.1.10.29...
    >> >> >>
    >> >> >> Hello,
    >> >> >> Thanks for your response. But, I did look into the PSDK help but

    was
    >> >not
    >> >> >> able to find what I was looking for. Here's what I am currently

    >doing:
    >> >> >>
    >> >> >> In my Form.KeyDown event, I make a call to isStickyKeysOn method

    and
    >> if
    >> >> it
    >> >> >> is on, then I want to know which of the keyboard keys were pressed.

    >> For
    >> >> >eg:
    >> >> >> if the keyboard keys that were pressed were Alt and 'A' then, I

    >would
    >> >> >perform
    >> >> >> the corresponding action for Alt+A. The part I am not sure how to

    do
    >> is
    >> >> to
    >> >> >> - get the array of keycodes for the keys that were pressed.
    >> >> >>
    >> >> >> I looked into the GetKeyboardState API call. But, using that would
    >> >require
    >> >> >> me to go through all the 256 characters in the list and find out

    the
    >> >ones
    >> >> >> that are on (pressed). Is there any other way of doing this.
    >> >> >>
    >> >> >> Could yo please point me to the help topic that you have mentioned.
    >> >> >> Your help is much appreciated.
    >> >> >> thanks,
    >> >> >> -Vasantha
    >> >> >>
    >> >> >> Public Function isStickyKeysOn() As Boolean
    >> >> >> Dim mk As STICKYKEYS
    >> >> >> Dim retval As Long
    >> >> >>
    >> >> >> mk.cbSize = Len(mk)
    >> >> >> ' Load the MouseKeys settings into the structure.
    >> >> >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk,

    0)
    >> >> >>
    >> >> >> If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    >> >> >> isStickyKeysOn = True
    >> >> >> Else
    >> >> >> isStickyKeysOn = False
    >> >> >> End If
    >> >> >>
    >> >> >> End Function
    >> >> >>
    >> >> >>
    >> >> >> "
    >> >> >> Michael \(michka\) Kaplan"

    ><former_mvp@nospam.trigeminal.spamless.com>
    >> >> >wrote:
    >> >> >> >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK help
    >> >topic
    >> >> >> for
    >> >> >> >the flags to check for....
    >> >> >> >
    >> >> >> >
    >> >> >> >--
    >> >> >> >MichKa
    >> >> >> >
    >> >> >> >Michael Kaplan
    >> >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >> >> >
    >> >> >> >International VB? -- http://www.i18nWithVB.com/
    >> >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >> >> >
    >> >> >> >
    >> >> >> >"Vasantha" <vasantha@us.ibm.com> wrote in message
    >> >> >> >news:3ceef13d@10.1.10.29...
    >> >> >> >>
    >> >> >> >> Hi,
    >> >> >> >>
    >> >> >> >> I am trying to find out what system call I should use in order

    to
    >> be
    >> >> >able
    >> >> >> >> to read the array of key strokes that the user entered.
    >> >> >> >> I am using the "SystemParametersInfo" call to find if the

    >stickkeys
    >> >> in
    >> >> >> the
    >> >> >> >> system accessibility settings are set to "ON" or "OFF". I have

    >this
    >> >> >part
    >> >> >> >> working.
    >> >> >> >> FYI: sticky keys are turned on in case the user is not able to

    >click
    >> >> on
    >> >> >> >multiple
    >> >> >> >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del,

    by
    >> >> >setting
    >> >> >> >> the sticky keys ON, the user can click on the Ctrl, the Alt and

    >> the
    >> >> Del
    >> >> >> >buttons
    >> >> >> >> individually one at a time and accomplish this.
    >> >> >> >>
    >> >> >> >> So, my next task is to read from the system the keys that were
    >> >entered
    >> >> >> and
    >> >> >> >> then using that information, I can divert control to the various
    >> >parts
    >> >> >> of
    >> >> >> >> my application. This is the part I am not sure how to do.
    >> >> >> >>
    >> >> >> >> I was told by another colleague that this could be accomplished

    >> by
    >> >> >making
    >> >> >> >> another call to "SystemParametersInfo" but using different
    >> >parameter.
    >> >> >> But,
    >> >> >> >> I have not been able to figure this out as yet.
    >> >> >> >>
    >> >> >> >> Any help in this regard would be greatly appreciated.
    >> >> >> >> Thanks for your help in advance.
    >> >> >> >>
    >> >> >> >> -Vasantha
    >> >> >> >>
    >> >> >> >
    >> >> >> >
    >> >> >>
    >> >> >
    >> >> >
    >> >>
    >> >
    >> >

    >>

    >
    >



  8. #8
    Michael \(michka\) Kaplan Guest

    Re: get the array of keycodes for the keys that were pressed

    "Vasantha" <vb.@127.0.0.1> wrote...

    > Thanks. Here are my declarations and I have also included the part of the
    > winuser.h file from where I copied the constant values for the dwFlags.
    > And, ok I will stop testing on NT since it is not supported there.
    >
    > >1) Use the HEX form of the dwFlags value so you can compare them to the
    > >constants

    >
    > Are you suggesting that I directly compare the dwFlags value to that of

    the
    > constants? I was under the understanding that each of these flags were

    represented
    > by a certain bit in the value of the dwFlags and the value of the dwFlags
    > itself is not of much use. Is this correct or have I misunderstood your

    suggestion?

    You have misunderstood.

    I am saying that since you are looking for hex numbers it is MUCH easier to
    read FF than it is to read 255, for the sake of comparison.

    > my code follows:
    > -----------------------------------------------------------
    > 'STICKY KEYS implementation
    > Declare Function SystemParametersInfo Lib "user32.dll" Alias

    "SystemParametersInfoA"
    > (ByVal uAction As Long, ByVal uiParam As Long, pvParam As Any, ByVal

    fWinIni
    > As Long) As Long
    >
    > Type STICKYKEYS
    > cbSize As Long
    > dwFlags As Long
    > End Type
    >
    > Public Const SKF_AUDIBLEFEEDBACK = &H40
    > Public Const SKF_AVAILABLE = &H2
    > Public Const SKF_CONFIRMHOTKEY = &H8
    > Public Const SKF_HOTKEYACTIVE = &H4
    > Public Const SKF_HOTKEYSOUND = &H10
    > Public Const SKF_INDICATOR = &H20
    > Public Const SKF_STICKYKEYSON = &H1
    > Public Const SKF_TRISTATE = &H80
    > Public Const SKF_TWOKEYSOFF = &H100
    > Public Const SPI_GETSTICKYKEYS = 58


    All of the SKFs above are wrong a they need to be LONGs, not integers. Try
    adding an & to the end so that (for example) SKF_TWOKEYSOFF is &H100&, not
    &H100.

    The best thing to do is to always add the & and then if VB takes it off you
    know the number is big enough not to need it.

    > Public Const SKF_LALTLATCHED = &H10000000
    > Public Const SKF_RALTLATCHED = &H20000000
    > Public Const SKF_LALTLOCKED = &H100000
    > Public Const SKF_RALTLOCKED = &H200000
    > Public Const SKF_LSHIFTLATCHED = &H1000000
    > Public Const SKF_RSHIFTLATCHED = &H2000000
    >
    > Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    > Dim mk As STICKYKEYS ' holds settings for StickyKeys
    > Dim retval As Long ' return value
    >
    > mk.cbSize = Len(mk) ' set the size of the structure
    > retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0) '

    don't
    > need to notify
    >
    > If (mk.dwFlags And SKF_STICKYKEYSON) Then
    > Debug.Print "STICKY KEY is on."
    >
    > If (mk.dwFlags And SKF_LALTLATCHED) Then
    > Debug.Print "Left Alt key is latched "
    > isStickyKeysOnAndALTKeyLatched = True
    > End If
    >
    > If (mk.dwFlags And SKF_RALTLATCHED) Then
    > Debug.Print "Right Alt key is latched "
    > isStickyKeysOnAndALTKeyLatched = True
    > End If
    >
    > Else
    > Debug.Print "STICKY KEY is OFF."
    > isStickyKeysOnAndALTKeyLatched = False
    > End If
    >
    > End Function
    >
    > --------------------------------------------------------------------------

    -
    > Here's part of the winuser.h file from where I copied the constant values.
    >
    > typedef struct tagSTICKYKEYS
    > {
    > UINT cbSize;
    > DWORD dwFlags;
    > } STICKYKEYS, *LPSTICKYKEYS;
    >
    > /*
    > * STICKYKEYS dwFlags field
    > */
    > #define SKF_STICKYKEYSON 0x00000001
    > #define SKF_AVAILABLE 0x00000002
    > #define SKF_HOTKEYACTIVE 0x00000004
    > #define SKF_CONFIRMHOTKEY 0x00000008
    > #define SKF_HOTKEYSOUND 0x00000010
    > #define SKF_INDICATOR 0x00000020
    > #define SKF_AUDIBLEFEEDBACK 0x00000040
    > #define SKF_TRISTATE 0x00000080
    > #define SKF_TWOKEYSOFF 0x00000100
    > #if(_WIN32_WINNT >= 0x0500)
    > #define SKF_LALTLATCHED 0x10000000
    > #define SKF_LCTLLATCHED 0x04000000
    > #define SKF_LSHIFTLATCHED 0x01000000
    > #define SKF_RALTLATCHED 0x20000000
    > #define SKF_RCTLLATCHED 0x08000000
    > #define SKF_RSHIFTLATCHED 0x02000000
    > #define SKF_LWINLATCHED 0x40000000
    > #define SKF_RWINLATCHED 0x80000000
    > #define SKF_LALTLOCKED 0x00100000
    > #define SKF_LCTLLOCKED 0x00040000
    > #define SKF_LSHIFTLOCKED 0x00010000
    > #define SKF_RALTLOCKED 0x00200000
    > #define SKF_RCTLLOCKED 0x00080000
    > #define SKF_RSHIFTLOCKED 0x00020000
    > #define SKF_LWINLOCKED 0x00400000
    > #define SKF_RWINLOCKED 0x00800000
    > #endif /* _WIN32_WINNT >= 0x0500 */
    >
    > -------------------------------------------------------------------------
    >
    > Thanks for your help.
    >
    > -Vasantha
    >
    >
    > "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    wrote:
    > >I do not know what your declarations are for the type or the API, I

    suspect
    > >they are flawed. A few items:
    > >
    > >1) Use the HEX form of the dwFlags value so you can compare them to the
    > >constants
    > >
    > >2) Stop trying to use NT4, it is not supported there
    > >
    > >3) Post your declarations, etc.
    > >
    > >
    > >--
    > >MichKa
    > >
    > >Michael Kaplan
    > >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >
    > >International VB? -- http://www.i18nWithVB.com/
    > >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >
    > >
    > >"Vasantha" <vb.@127.0.0.1> wrote in message news:3cffab99$1@10.1.10.29...
    > >>
    > >> The current state of the sticky keys is 'ON' and the value of dwFlags

    > is
    > >475
    > >> (when tested on WinNT) and 255 (when tested on Windows 2000). These are

    > >the
    > >> values I see when debugging the code when I press the ALT key.
    > >> Thanks a lot for your response. I really appreciate all your help.
    > >>
    > >> -Vasantha
    > >>
    > >> "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    > >wrote:
    > >> >What is the exact numeric value of dwFlags and what is the current

    state
    > >> of
    > >> >the sticky keys when that number is what is there?
    > >> >
    > >> >
    > >> >--
    > >> >MichKa
    > >> >
    > >> >Michael Kaplan
    > >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >> >
    > >> >International VB? -- http://www.i18nWithVB.com/
    > >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >> >
    > >> >
    > >> >"vasantha" <vb.@127.0.0.1> wrote in message

    news:3cfcf74a$1@10.1.10.29...
    > >> >>
    > >> >> Thanks for pointing it out to me. I needed to program the shortcut

    > keys
    > >> so
    > >> >> I am now checking for the additional flags such as

    > >SKF_LALTLATCHED(Right
    > >> >> Alt Key press) and SKF_RALTLATCHED (left Alt Key press).
    > >> >>
    > >> >> The PSDK help indicates that SKF_LALTLATCHED and SKF_RALTLATCHED are
    > >> >supported
    > >> >> in Windows 98 and 2000.
    > >> >>
    > >>

    >
    >>http://msdn.microsoft.com/library/de...n-us/msaa/acce

    s
    > >s
    > >> >_1alu.asp
    > >> >>
    > >> >> I have tried my test case on Windows NT as well as Windows 2000 and

    > I
    > >> have
    > >> >> not been able to successfully use it. I do a bit wise AND on the

    > >dwFlags
    > >> >> (that I receive from the sticky keys strcture) and the constant
    > >> >SKF_LALTLATCHED.
    > >> >> This always returns a value of 0. My understanding is that it should
    > >> >return
    > >> >> a value of 1 if it is 'ON' and a value of '0' if it is 'OFF'. Is

    this
    > >> >approach
    > >> >> correct?
    > >> >>
    > >> >> Also, if possible could you please point me to any such sample code
    > >> >snippets
    > >> >> that you might have come across.
    > >> >>
    > >> >> Thanks a lot for your help.
    > >> >>
    > >> >> -Vasantha
    > >> >>
    > >> >>
    > >> >> my code follows:
    > >> >> 'Constants values are as declared in Winuser.h file
    > >> >> Public Const SKF_LALTLATCHED = &H10000000
    > >> >> Public Const SKF_RALTLATCHED = &H20000000
    > >> >>
    > >> >> Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    > >> >> Dim mk As STICKYKEYS ' holds settings for StickyKeys
    > >> >> Dim retval As Long ' return value
    > >> >>
    > >> >> mk.cbSize = Len(mk) ' set the size of the structure
    > >> >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)
    > >> '
    > >> >don't
    > >> >> need to notify
    > >> >>
    > >> >> If (mk.dwFlags And SKF_STICKYKEYSON) Then
    > >> >> Debug.Print "STICKY KEY is on."
    > >> >>
    > >> >> If (mk.dwFlags And SKF_LALTLATCHED) Then
    > >> >> Debug.Print "Left Alt key is latched "
    > >> >> isStickyKeysOnAndALTKeyLatched = True
    > >> >> End If
    > >> >>
    > >> >> If (mk.dwFlags And SKF_RALTLATCHED) Then
    > >> >> Debug.Print "Right Alt key is latched "
    > >> >> isStickyKeysOnAndALTKeyLatched = True
    > >> >> End If
    > >> >>
    > >> >> Else
    > >> >> Debug.Print "STICKY KEY is OFF."
    > >> >> isStickyKeysOnAndALTKeyLatched = False
    > >> >> End If
    > >> >>
    > >> >> End Function
    > >> >>
    > >> >>
    > >> >>
    > >> >> "Michael \(michka\) Kaplan"

    <former_mvp@nospam.trigeminal.spamless.com>
    > >> >wrote:
    > >> >> >It is the same API you are already using!!!
    > >> >> >
    > >> >> >You are currently checking for a single flag -- SKF_STICKYKEYSON.

    > You
    > >> >have
    > >> >> >to check for some of the other flags, thats all.
    > >> >> >
    > >> >> >
    > >> >> >--
    > >> >> >MichKa
    > >> >> >
    > >> >> >Michael Kaplan
    > >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >> >> >
    > >> >> >International VB? -- http://www.i18nWithVB.com/
    > >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >> >> >
    > >> >> >
    > >> >> >
    > >> >> >"vasantha" <vasantha@us.ibm.com> wrote in message
    > >> >> >news:3cf7fa4d$1@10.1.10.29...
    > >> >> >>
    > >> >> >> Hello,
    > >> >> >> Thanks for your response. But, I did look into the PSDK help but

    > was
    > >> >not
    > >> >> >> able to find what I was looking for. Here's what I am currently

    > >doing:
    > >> >> >>
    > >> >> >> In my Form.KeyDown event, I make a call to isStickyKeysOn method

    > and
    > >> if
    > >> >> it
    > >> >> >> is on, then I want to know which of the keyboard keys were

    pressed.
    > >> For
    > >> >> >eg:
    > >> >> >> if the keyboard keys that were pressed were Alt and 'A' then, I

    > >would
    > >> >> >perform
    > >> >> >> the corresponding action for Alt+A. The part I am not sure how to

    > do
    > >> is
    > >> >> to
    > >> >> >> - get the array of keycodes for the keys that were pressed.
    > >> >> >>
    > >> >> >> I looked into the GetKeyboardState API call. But, using that

    would
    > >> >require
    > >> >> >> me to go through all the 256 characters in the list and find out

    > the
    > >> >ones
    > >> >> >> that are on (pressed). Is there any other way of doing this.
    > >> >> >>
    > >> >> >> Could yo please point me to the help topic that you have

    mentioned.
    > >> >> >> Your help is much appreciated.
    > >> >> >> thanks,
    > >> >> >> -Vasantha
    > >> >> >>
    > >> >> >> Public Function isStickyKeysOn() As Boolean
    > >> >> >> Dim mk As STICKYKEYS
    > >> >> >> Dim retval As Long
    > >> >> >>
    > >> >> >> mk.cbSize = Len(mk)
    > >> >> >> ' Load the MouseKeys settings into the structure.
    > >> >> >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk,

    > 0)
    > >> >> >>
    > >> >> >> If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    > >> >> >> isStickyKeysOn = True
    > >> >> >> Else
    > >> >> >> isStickyKeysOn = False
    > >> >> >> End If
    > >> >> >>
    > >> >> >> End Function
    > >> >> >>
    > >> >> >>
    > >> >> >> "
    > >> >> >> Michael \(michka\) Kaplan"

    > ><former_mvp@nospam.trigeminal.spamless.com>
    > >> >> >wrote:
    > >> >> >> >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK

    help
    > >> >topic
    > >> >> >> for
    > >> >> >> >the flags to check for....
    > >> >> >> >
    > >> >> >> >
    > >> >> >> >--
    > >> >> >> >MichKa
    > >> >> >> >
    > >> >> >> >Michael Kaplan
    > >> >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    > >> >> >> >
    > >> >> >> >International VB? -- http://www.i18nWithVB.com/
    > >> >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    > >> >> >> >
    > >> >> >> >
    > >> >> >> >"Vasantha" <vasantha@us.ibm.com> wrote in message
    > >> >> >> >news:3ceef13d@10.1.10.29...
    > >> >> >> >>
    > >> >> >> >> Hi,
    > >> >> >> >>
    > >> >> >> >> I am trying to find out what system call I should use in order

    > to
    > >> be
    > >> >> >able
    > >> >> >> >> to read the array of key strokes that the user entered.
    > >> >> >> >> I am using the "SystemParametersInfo" call to find if the

    > >stickkeys
    > >> >> in
    > >> >> >> the
    > >> >> >> >> system accessibility settings are set to "ON" or "OFF". I have

    > >this
    > >> >> >part
    > >> >> >> >> working.
    > >> >> >> >> FYI: sticky keys are turned on in case the user is not able to

    > >click
    > >> >> on
    > >> >> >> >multiple
    > >> >> >> >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del,

    > by
    > >> >> >setting
    > >> >> >> >> the sticky keys ON, the user can click on the Ctrl, the Alt

    and
    > >> the
    > >> >> Del
    > >> >> >> >buttons
    > >> >> >> >> individually one at a time and accomplish this.
    > >> >> >> >>
    > >> >> >> >> So, my next task is to read from the system the keys that were
    > >> >entered
    > >> >> >> and
    > >> >> >> >> then using that information, I can divert control to the

    various
    > >> >parts
    > >> >> >> of
    > >> >> >> >> my application. This is the part I am not sure how to do.
    > >> >> >> >>
    > >> >> >> >> I was told by another colleague that this could be

    accomplished
    > >> by
    > >> >> >making
    > >> >> >> >> another call to "SystemParametersInfo" but using different
    > >> >parameter.
    > >> >> >> But,
    > >> >> >> >> I have not been able to figure this out as yet.
    > >> >> >> >>
    > >> >> >> >> Any help in this regard would be greatly appreciated.
    > >> >> >> >> Thanks for your help in advance.
    > >> >> >> >>
    > >> >> >> >> -Vasantha
    > >> >> >> >>
    > >> >> >> >
    > >> >> >> >
    > >> >> >>
    > >> >> >
    > >> >> >
    > >> >>
    > >> >
    > >> >
    > >>

    > >
    > >

    >




  9. #9
    Vasantha Guest

    Re: get the array of keycodes for the keys that were pressed


    Thanks. I greatly appreciate all your help.
    I got it to work on Win 2000.

    -Vasantha

    "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com> wrote:
    >"Vasantha" <vb.@127.0.0.1> wrote...
    >
    >> Thanks. Here are my declarations and I have also included the part of

    the
    >> winuser.h file from where I copied the constant values for the dwFlags.
    >> And, ok I will stop testing on NT since it is not supported there.
    >>
    >> >1) Use the HEX form of the dwFlags value so you can compare them to the
    >> >constants

    >>
    >> Are you suggesting that I directly compare the dwFlags value to that of

    >the
    >> constants? I was under the understanding that each of these flags were

    >represented
    >> by a certain bit in the value of the dwFlags and the value of the dwFlags
    >> itself is not of much use. Is this correct or have I misunderstood your

    >suggestion?
    >
    >You have misunderstood.
    >
    >I am saying that since you are looking for hex numbers it is MUCH easier

    to
    >read FF than it is to read 255, for the sake of comparison.
    >
    >> my code follows:
    >> -----------------------------------------------------------
    >> 'STICKY KEYS implementation
    >> Declare Function SystemParametersInfo Lib "user32.dll" Alias

    >"SystemParametersInfoA"
    >> (ByVal uAction As Long, ByVal uiParam As Long, pvParam As Any, ByVal

    >fWinIni
    >> As Long) As Long
    >>
    >> Type STICKYKEYS
    >> cbSize As Long
    >> dwFlags As Long
    >> End Type
    >>
    >> Public Const SKF_AUDIBLEFEEDBACK = &H40
    >> Public Const SKF_AVAILABLE = &H2
    >> Public Const SKF_CONFIRMHOTKEY = &H8
    >> Public Const SKF_HOTKEYACTIVE = &H4
    >> Public Const SKF_HOTKEYSOUND = &H10
    >> Public Const SKF_INDICATOR = &H20
    >> Public Const SKF_STICKYKEYSON = &H1
    >> Public Const SKF_TRISTATE = &H80
    >> Public Const SKF_TWOKEYSOFF = &H100
    >> Public Const SPI_GETSTICKYKEYS = 58

    >
    >All of the SKFs above are wrong a they need to be LONGs, not integers. Try
    >adding an & to the end so that (for example) SKF_TWOKEYSOFF is &H100&, not
    >&H100.
    >
    >The best thing to do is to always add the & and then if VB takes it off

    you
    >know the number is big enough not to need it.
    >
    >> Public Const SKF_LALTLATCHED = &H10000000
    >> Public Const SKF_RALTLATCHED = &H20000000
    >> Public Const SKF_LALTLOCKED = &H100000
    >> Public Const SKF_RALTLOCKED = &H200000
    >> Public Const SKF_LSHIFTLATCHED = &H1000000
    >> Public Const SKF_RSHIFTLATCHED = &H2000000
    >>
    >> Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    >> Dim mk As STICKYKEYS ' holds settings for StickyKeys
    >> Dim retval As Long ' return value
    >>
    >> mk.cbSize = Len(mk) ' set the size of the structure
    >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk, 0)

    '
    >don't
    >> need to notify
    >>
    >> If (mk.dwFlags And SKF_STICKYKEYSON) Then
    >> Debug.Print "STICKY KEY is on."
    >>
    >> If (mk.dwFlags And SKF_LALTLATCHED) Then
    >> Debug.Print "Left Alt key is latched "
    >> isStickyKeysOnAndALTKeyLatched = True
    >> End If
    >>
    >> If (mk.dwFlags And SKF_RALTLATCHED) Then
    >> Debug.Print "Right Alt key is latched "
    >> isStickyKeysOnAndALTKeyLatched = True
    >> End If
    >>
    >> Else
    >> Debug.Print "STICKY KEY is OFF."
    >> isStickyKeysOnAndALTKeyLatched = False
    >> End If
    >>
    >> End Function
    >>
    >> --------------------------------------------------------------------------

    >-
    >> Here's part of the winuser.h file from where I copied the constant values.
    >>
    >> typedef struct tagSTICKYKEYS
    >> {
    >> UINT cbSize;
    >> DWORD dwFlags;
    >> } STICKYKEYS, *LPSTICKYKEYS;
    >>
    >> /*
    >> * STICKYKEYS dwFlags field
    >> */
    >> #define SKF_STICKYKEYSON 0x00000001
    >> #define SKF_AVAILABLE 0x00000002
    >> #define SKF_HOTKEYACTIVE 0x00000004
    >> #define SKF_CONFIRMHOTKEY 0x00000008
    >> #define SKF_HOTKEYSOUND 0x00000010
    >> #define SKF_INDICATOR 0x00000020
    >> #define SKF_AUDIBLEFEEDBACK 0x00000040
    >> #define SKF_TRISTATE 0x00000080
    >> #define SKF_TWOKEYSOFF 0x00000100
    >> #if(_WIN32_WINNT >= 0x0500)
    >> #define SKF_LALTLATCHED 0x10000000
    >> #define SKF_LCTLLATCHED 0x04000000
    >> #define SKF_LSHIFTLATCHED 0x01000000
    >> #define SKF_RALTLATCHED 0x20000000
    >> #define SKF_RCTLLATCHED 0x08000000
    >> #define SKF_RSHIFTLATCHED 0x02000000
    >> #define SKF_LWINLATCHED 0x40000000
    >> #define SKF_RWINLATCHED 0x80000000
    >> #define SKF_LALTLOCKED 0x00100000
    >> #define SKF_LCTLLOCKED 0x00040000
    >> #define SKF_LSHIFTLOCKED 0x00010000
    >> #define SKF_RALTLOCKED 0x00200000
    >> #define SKF_RCTLLOCKED 0x00080000
    >> #define SKF_RSHIFTLOCKED 0x00020000
    >> #define SKF_LWINLOCKED 0x00400000
    >> #define SKF_RWINLOCKED 0x00800000
    >> #endif /* _WIN32_WINNT >= 0x0500 */
    >>
    >> -------------------------------------------------------------------------
    >>
    >> Thanks for your help.
    >>
    >> -Vasantha
    >>
    >>
    >> "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>

    >wrote:
    >> >I do not know what your declarations are for the type or the API, I

    >suspect
    >> >they are flawed. A few items:
    >> >
    >> >1) Use the HEX form of the dwFlags value so you can compare them to the
    >> >constants
    >> >
    >> >2) Stop trying to use NT4, it is not supported there
    >> >
    >> >3) Post your declarations, etc.
    >> >
    >> >
    >> >--
    >> >MichKa
    >> >
    >> >Michael Kaplan
    >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >
    >> >International VB? -- http://www.i18nWithVB.com/
    >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >
    >> >
    >> >"Vasantha" <vb.@127.0.0.1> wrote in message news:3cffab99$1@10.1.10.29...
    >> >>
    >> >> The current state of the sticky keys is 'ON' and the value of dwFlags

    >> is
    >> >475
    >> >> (when tested on WinNT) and 255 (when tested on Windows 2000). These

    are
    >> >the
    >> >> values I see when debugging the code when I press the ALT key.
    >> >> Thanks a lot for your response. I really appreciate all your help.
    >> >>
    >> >> -Vasantha
    >> >>
    >> >> "Michael \(michka\) Kaplan" <former_mvp@nospam.trigeminal.spamless.com>
    >> >wrote:
    >> >> >What is the exact numeric value of dwFlags and what is the current

    >state
    >> >> of
    >> >> >the sticky keys when that number is what is there?
    >> >> >
    >> >> >
    >> >> >--
    >> >> >MichKa
    >> >> >
    >> >> >Michael Kaplan
    >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >> >
    >> >> >International VB? -- http://www.i18nWithVB.com/
    >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >> >
    >> >> >
    >> >> >"vasantha" <vb.@127.0.0.1> wrote in message

    >news:3cfcf74a$1@10.1.10.29...
    >> >> >>
    >> >> >> Thanks for pointing it out to me. I needed to program the shortcut

    >> keys
    >> >> so
    >> >> >> I am now checking for the additional flags such as
    >> >SKF_LALTLATCHED(Right
    >> >> >> Alt Key press) and SKF_RALTLATCHED (left Alt Key press).
    >> >> >>
    >> >> >> The PSDK help indicates that SKF_LALTLATCHED and SKF_RALTLATCHED

    are
    >> >> >supported
    >> >> >> in Windows 98 and 2000.
    >> >> >>
    >> >>

    >>
    >>>http://msdn.microsoft.com/library/de...n-us/msaa/acce

    >s
    >> >s
    >> >> >_1alu.asp
    >> >> >>
    >> >> >> I have tried my test case on Windows NT as well as Windows 2000

    and
    >> I
    >> >> have
    >> >> >> not been able to successfully use it. I do a bit wise AND on the
    >> >dwFlags
    >> >> >> (that I receive from the sticky keys strcture) and the constant
    >> >> >SKF_LALTLATCHED.
    >> >> >> This always returns a value of 0. My understanding is that it should
    >> >> >return
    >> >> >> a value of 1 if it is 'ON' and a value of '0' if it is 'OFF'. Is

    >this
    >> >> >approach
    >> >> >> correct?
    >> >> >>
    >> >> >> Also, if possible could you please point me to any such sample code
    >> >> >snippets
    >> >> >> that you might have come across.
    >> >> >>
    >> >> >> Thanks a lot for your help.
    >> >> >>
    >> >> >> -Vasantha
    >> >> >>
    >> >> >>
    >> >> >> my code follows:
    >> >> >> 'Constants values are as declared in Winuser.h file
    >> >> >> Public Const SKF_LALTLATCHED = &H10000000
    >> >> >> Public Const SKF_RALTLATCHED = &H20000000
    >> >> >>
    >> >> >> Public Function isStickyKeysOnAndALTKeyLatched() As Boolean
    >> >> >> Dim mk As STICKYKEYS ' holds settings for StickyKeys
    >> >> >> Dim retval As Long ' return value
    >> >> >>
    >> >> >> mk.cbSize = Len(mk) ' set the size of the structure
    >> >> >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk), mk,

    0)
    >> >> '
    >> >> >don't
    >> >> >> need to notify
    >> >> >>
    >> >> >> If (mk.dwFlags And SKF_STICKYKEYSON) Then
    >> >> >> Debug.Print "STICKY KEY is on."
    >> >> >>
    >> >> >> If (mk.dwFlags And SKF_LALTLATCHED) Then
    >> >> >> Debug.Print "Left Alt key is latched "
    >> >> >> isStickyKeysOnAndALTKeyLatched = True
    >> >> >> End If
    >> >> >>
    >> >> >> If (mk.dwFlags And SKF_RALTLATCHED) Then
    >> >> >> Debug.Print "Right Alt key is latched "
    >> >> >> isStickyKeysOnAndALTKeyLatched = True
    >> >> >> End If
    >> >> >>
    >> >> >> Else
    >> >> >> Debug.Print "STICKY KEY is OFF."
    >> >> >> isStickyKeysOnAndALTKeyLatched = False
    >> >> >> End If
    >> >> >>
    >> >> >> End Function
    >> >> >>
    >> >> >>
    >> >> >>
    >> >> >> "Michael \(michka\) Kaplan"

    ><former_mvp@nospam.trigeminal.spamless.com>
    >> >> >wrote:
    >> >> >> >It is the same API you are already using!!!
    >> >> >> >
    >> >> >> >You are currently checking for a single flag -- SKF_STICKYKEYSON.

    >> You
    >> >> >have
    >> >> >> >to check for some of the other flags, thats all.
    >> >> >> >
    >> >> >> >
    >> >> >> >--
    >> >> >> >MichKa
    >> >> >> >
    >> >> >> >Michael Kaplan
    >> >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >> >> >
    >> >> >> >International VB? -- http://www.i18nWithVB.com/
    >> >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >> >> >
    >> >> >> >
    >> >> >> >
    >> >> >> >"vasantha" <vasantha@us.ibm.com> wrote in message
    >> >> >> >news:3cf7fa4d$1@10.1.10.29...
    >> >> >> >>
    >> >> >> >> Hello,
    >> >> >> >> Thanks for your response. But, I did look into the PSDK help

    but
    >> was
    >> >> >not
    >> >> >> >> able to find what I was looking for. Here's what I am currently
    >> >doing:
    >> >> >> >>
    >> >> >> >> In my Form.KeyDown event, I make a call to isStickyKeysOn method

    >> and
    >> >> if
    >> >> >> it
    >> >> >> >> is on, then I want to know which of the keyboard keys were

    >pressed.
    >> >> For
    >> >> >> >eg:
    >> >> >> >> if the keyboard keys that were pressed were Alt and 'A' then,

    I
    >> >would
    >> >> >> >perform
    >> >> >> >> the corresponding action for Alt+A. The part I am not sure how

    to
    >> do
    >> >> is
    >> >> >> to
    >> >> >> >> - get the array of keycodes for the keys that were pressed.
    >> >> >> >>
    >> >> >> >> I looked into the GetKeyboardState API call. But, using that

    >would
    >> >> >require
    >> >> >> >> me to go through all the 256 characters in the list and find

    out
    >> the
    >> >> >ones
    >> >> >> >> that are on (pressed). Is there any other way of doing this.
    >> >> >> >>
    >> >> >> >> Could yo please point me to the help topic that you have

    >mentioned.
    >> >> >> >> Your help is much appreciated.
    >> >> >> >> thanks,
    >> >> >> >> -Vasantha
    >> >> >> >>
    >> >> >> >> Public Function isStickyKeysOn() As Boolean
    >> >> >> >> Dim mk As STICKYKEYS
    >> >> >> >> Dim retval As Long
    >> >> >> >>
    >> >> >> >> mk.cbSize = Len(mk)
    >> >> >> >> ' Load the MouseKeys settings into the structure.
    >> >> >> >> retval = SystemParametersInfo(SPI_GETSTICKYKEYS, Len(mk),

    mk,
    >> 0)
    >> >> >> >>
    >> >> >> >> If (mk.dwFlags And SKF_STICKYKEYSON) = SKF_STICKYKEYSON Then
    >> >> >> >> isStickyKeysOn = True
    >> >> >> >> Else
    >> >> >> >> isStickyKeysOn = False
    >> >> >> >> End If
    >> >> >> >>
    >> >> >> >> End Function
    >> >> >> >>
    >> >> >> >>
    >> >> >> >> "
    >> >> >> >> Michael \(michka\) Kaplan"
    >> ><former_mvp@nospam.trigeminal.spamless.com>
    >> >> >> >wrote:
    >> >> >> >> >Its just with the SPI_GETSTICKYKEYS param. Check out the PSDK

    >help
    >> >> >topic
    >> >> >> >> for
    >> >> >> >> >the flags to check for....
    >> >> >> >> >
    >> >> >> >> >
    >> >> >> >> >--
    >> >> >> >> >MichKa
    >> >> >> >> >
    >> >> >> >> >Michael Kaplan
    >> >> >> >> >Trigeminal Software, Inc. -- http://www.trigeminal.com/
    >> >> >> >> >
    >> >> >> >> >International VB? -- http://www.i18nWithVB.com/
    >> >> >> >> >C++? MSLU -- http://msdn.microsoft.com/msdnmag/issues/01/10/
    >> >> >> >> >
    >> >> >> >> >
    >> >> >> >> >"Vasantha" <vasantha@us.ibm.com> wrote in message
    >> >> >> >> >news:3ceef13d@10.1.10.29...
    >> >> >> >> >>
    >> >> >> >> >> Hi,
    >> >> >> >> >>
    >> >> >> >> >> I am trying to find out what system call I should use in order

    >> to
    >> >> be
    >> >> >> >able
    >> >> >> >> >> to read the array of key strokes that the user entered.
    >> >> >> >> >> I am using the "SystemParametersInfo" call to find if the
    >> >stickkeys
    >> >> >> in
    >> >> >> >> the
    >> >> >> >> >> system accessibility settings are set to "ON" or "OFF". I

    have
    >> >this
    >> >> >> >part
    >> >> >> >> >> working.
    >> >> >> >> >> FYI: sticky keys are turned on in case the user is not able

    to
    >> >click
    >> >> >> on
    >> >> >> >> >multiple
    >> >> >> >> >> keys at a time. For eg: to accomplish the usual Ctrl+Alt+Del,

    >> by
    >> >> >> >setting
    >> >> >> >> >> the sticky keys ON, the user can click on the Ctrl, the Alt

    >and
    >> >> the
    >> >> >> Del
    >> >> >> >> >buttons
    >> >> >> >> >> individually one at a time and accomplish this.
    >> >> >> >> >>
    >> >> >> >> >> So, my next task is to read from the system the keys that

    were
    >> >> >entered
    >> >> >> >> and
    >> >> >> >> >> then using that information, I can divert control to the

    >various
    >> >> >parts
    >> >> >> >> of
    >> >> >> >> >> my application. This is the part I am not sure how to do.
    >> >> >> >> >>
    >> >> >> >> >> I was told by another colleague that this could be

    >accomplished
    >> >> by
    >> >> >> >making
    >> >> >> >> >> another call to "SystemParametersInfo" but using different
    >> >> >parameter.
    >> >> >> >> But,
    >> >> >> >> >> I have not been able to figure this out as yet.
    >> >> >> >> >>
    >> >> >> >> >> Any help in this regard would be greatly appreciated.
    >> >> >> >> >> Thanks for your help in advance.
    >> >> >> >> >>
    >> >> >> >> >> -Vasantha
    >> >> >> >> >>
    >> >> >> >> >
    >> >> >> >> >
    >> >> >> >>
    >> >> >> >
    >> >> >> >
    >> >> >>
    >> >> >
    >> >> >
    >> >>
    >> >
    >> >

    >>

    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center