Capturing Key States from a Non-active Window

Sometimes you need to determine whether a particular key is pressed or not?even though the application is not active. “GetAsyncKeyState” comes to the rescue. This function takes a virtual key code as a parameter and returns non-zero if the function succeeds.

Here’s a sample app for capturing the ‘F5’ key. In this example, I call GetAsyncKeyState in a timer, so that it can capture the key press event.

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As IntegerPrivate Const VK_F5 = &H74Private Sub Timer1_Timer()    If GetAsyncKeyState(VK_F5) <> 0 Then        Text1.Text = "F5 Pressed..."    End IfEnd Sub
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a