• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 597
  • Last Modified:

VBShiftMask

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
Technokid
Asked:
Technokid
1 Solution
 
exjrainCommented:
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
 
aelatikCommented:
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
 
aelatikCommented:
If you want other variations look for keyloggers
0
 
RMatzkaCommented:
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
 
TechnokidAuthor Commented:
Also, do you know anything about how to determine if an IE window is a popup or not?

Thanks!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now