|
-
May 8th, 2009, 09:04 AM
#1
Thread Starter
Addicted Member
detect when F5 is pressed?
When F5 is pressed, i need to run a function, is there a stable way to do this? i remember before i found scripts run in timers with 1ms which didnt work too well.
Thanks for all your help here!
I will do my best to add you to the credits of my new apps.
-
May 8th, 2009, 09:50 AM
#2
Hyperactive Member
Re: detect when F5 is pressed?
Hey joey have tried getasyncstate, but for that you have to use timer :-
Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer
If GetAsyncKeyState(vbKeyF8) <> 0 Then
' Do something
End If
End Sub
set the time inerval to minimum....
hhope it'll work
-
May 8th, 2009, 10:20 AM
#3
Re: detect when F5 is pressed?
I id this in the KeyDown event but it can also be put in the KeyUp event if you wish.
Code:
Option Explicit
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 116 Then
MsgBox "F5 was pressed. Call your function here"
End If
End Sub
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|