?
Solved

VBShiftMask

Posted on 2003-02-25
5
Medium Priority
?
560 Views
Last Modified: 2007-12-19
How Can I detect the Shift key outside of my VB program?

i.e. - When no part of my program has the focus then, detect it.

Thanks!
0
Comment
Question by:Technokid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:exjrain
ID: 8020160
I think the keypress event has to be associated with an object such as your form.

However, I'm not sure if there is a vb object for your entire system.

Try desktop or parent or window or document or system

you should be able to do a keypress for one of those I would think. Let me know if it works.
0
 
LVL 14

Expert Comment

by:aelatik
ID: 8020176
Dim result As Integer

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub Timer1_Timer()

For i = 1 To 255
result = 0
result = GetAsyncKeyState(i)

If result = -32767 Then
If i = vbKeyShift Then
MsgBox "Yes"
End If
End If
Next i
End Sub
0
 
LVL 14

Expert Comment

by:aelatik
ID: 8020188
If you want other variations look for keyloggers
0
 

Accepted Solution

by:
RMatzka earned 160 total points
ID: 8021079
Well, aelatik's code does it, but you can have it shorter:

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub Timer1_Timer()
msgbox ((GetAsyncKeyState(vbKeyShift) And &H8000) = &H8000)
End Sub
0
 

Author Comment

by:Technokid
ID: 8024967
Also, do you know anything about how to determine if an IE window is a popup or not?

Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question