Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:19:41+00:00 2026-06-11T10:19:41+00:00

I am running into an odd problem with one particular line involving GetKeyState .

  • 0

I am running into an odd problem with one particular line involvingGetKeyState. I am attempting to detect a left mouse click of the Windows Start Button outside a form in Visual Basic 2010. The one particular line is very close to being successful but something is wrong. Specific information below.

Public Class Form1

    Public Declare Function GetKeyState Lib "user32" (ByVal vKey As Integer) As Short
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        If GetKeyState(91) < 0 And GetKeyState(1) < 0 Then
            MsgBox("Start Button clicked.")
        End If

    End Sub
End Class

If I change the line:

If GetKeyState(91) < 0 And GetKeyState(1) < 0 Then

to:

If GetKeyState(91) < 0 Then

I can trigger the MsgBox by clicking the Start Button – outside the form, using only the keyboard. Mouse clicking the Start Button has no response.

If I change the same line to:

If GetKeyState(1) < 0 Then 

I can trigger the MsgBox by clicking the left mouse button – outside the form, anywhere in the OS.

However when I try to combine what I perceive would be interpreted as a left mouse click of the Start Button:

If GetKeyState(91) < 0 And GetKeyState(1) < 0 Then

Nothing happens. How do I make it so the MsgBox is triggered when the mouse left-clicks the Start Button?

———————————-Question Addendum—————————————-

I understand now the distinction between the key on the keyboard vs. the button on the screen. Although the Windows Key triggers the Start Button, GetKeyState only accepts input from the keyboard. By name, it would seem that GetKeyState only concerns itself with the state of keys on the keyboard. However, I see a number of GetKeyState functions online that involve both keyboard and mouse.

But I must conclude that GetKeyState is not going to get me to my destination. I ran a program similar to Spy++ called Window Detective and it identifed the Start Button as Parent: Shell_traywnd and the child: Button.

So therefore, it would seem to me that I create something like the following:

myParent = FindWindow(vbNullString, “Shell_traywnd”)
myChild = FindWindowEx(myParent, 0, “Button”, vbNullString)

The question then is – how do I detect if the Child is clicked? In this instance, is the Start Button called a Handle? Or a Window? Also, I know of mouse position using X/Y but I don’t want to use that since a Start Button can be freely relocated in the Windows OS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:19:42+00:00Added an answer on June 11, 2026 at 10:19 am

    Your assumption is incorrect: the GetKeyState parameter of 91 (0x5B) refers to the left windows key on the keyboard, not the start button on the screen. I suspect you’ll need to check where the mouse click occurs.

    I’m no expert on this, but you could use Spy++ that comes with Visual Studio to peek at the windows messages involved in clicking the Start button.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using mercurial, I've run into an odd problem where a line from one committer
I'm running into an odd problem with a mail sending component in one of
I'm running into an odd problem with MEF's composition container and directory catalog where
I'm building my first Facebook Connect application, and am running into an odd problem.
I am running into an odd problem, and this is the only thing I
I'm running into an odd quirk involving Core Data, a declared protocol, and perhaps
I'm running into an odd problem where window.addEventListener (or window.attachEvent) doesn't seem to be
I seem to be running into an odd problem. When using my GWT application
So I am running into an odd problem. I have a pointer to a
I'm running into an odd problem with concatenating or printing strings. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.