+ Reply to Thread
Results 1 to 13 of 13

GetAsyncKeyState

  1. #1
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    GetAsyncKeyState

    I dont know if anyone here has used the following code


    Please Login or Register  to view this content.
    .. now i need to know where i can get corresponding &H values for combination key presses like say ctrl+m, shift+o or something like that...

    please help..
    Last edited by kishen1912; 08-27-2010 at 07:05 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: GetAsyncKeyState

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Did you try google?
    http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: GetAsyncKeyState

    sorry abt the code tag...
    btw the link u sent gave me hexadecimal values for all individual key strokes.. how do i use them to make a combination or keystrokes???

    i need to use a combination like say Ctrl+Shift+L to perform a certain function on my worksheet.
    Can you help

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: GetAsyncKeyState

    Did you read what the msdn articles said.

    GetAsyncKeyState Function

    Determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.
    So you simple call the function 3 times with the different keys you are testing for.

    Of course you gave no explanation of why you are using this API call so it could be there are other ways to determine the information you want.
    Perhaps using one of the other API functions mentioned, such as GetKeyboardState which returns the state of all the keys.

  5. #5
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: GetAsyncKeyState

    i need this for a dashboard for my client. he wants certain form controls hidden and to be visible only upon hitting a specific key combination ( the key combination is mine to decide on) .. i asked around my office one of my colleagues gave me the GetAsyncKeyState function... so was pursuing that path...

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: GetAsyncKeyState

    If you are controlling the key combinations look at using the .OnKey method rather than muck about with APIs.

    I guess your colleagues are developers not excel users.

  7. #7
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: GetAsyncKeyState

    but i dont think i can give the onkey function in a sheet selection change.. am i right ?

  8. #8
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: GetAsyncKeyState

    this is what my selection change looks like

    Please Login or Register  to view this content.
    Please note that the shape is my format controls that i am hiding or unhiding... here it is done by left and right keys..
    i need some combination in place of left or right.. !!

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: GetAsyncKeyState

    You said you had control over what key combination.
    And your choice is the Left and Right arrow with or without SHIFT key??

    If a user does CTRL+RIGHT surely they will jump straight to the last column on the sheet?

    If the user does SHIFT+RIGHT the selected area is extended.

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: GetAsyncKeyState

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: GetAsyncKeyState

    even if i press ctrl and shift and arrow keys only the arrow keys is being recorded as true...

    dunno if it works differently at your end... but for me the ctrl and shift is always shown as false

  12. #12
    Registered User
    Join Date
    08-16-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: GetAsyncKeyState

    sorry my bad.. i didnt declare shift and control.. !!!

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: GetAsyncKeyState

    if I press SHIFT+RIGHT it reports both as being true.

    If I press CTRL and then press RIGHT obviously only Right will be true.

    Pressing CTRL or SHIFT on their own will not cause the selection change event to fire.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1