Oppure

Loading
09/09/09 8:35
dylan666
Mi servirebbe di rilevare il rilascio del bottone sinistro del mouse dopo che lo si è premuto. Per la pressione, grazie all'aiuto che ho avuto su questo forum, sono arrivato al seguente codice:

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1
End Sub

Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyLButton) = -32768 Then
MsgBox "premuto"
End If
End Sub 


Per il rilascio credevosi potesse fare una cosa così:

Private Sub Timer2_Timer()
If GetAsyncKeyState(vbKeyLButton) = -32768 Then
'MsgBox "premuto"
Timer3.Enabled = True
End If
End Sub

Private Sub Timer3_Timer()
If GetAsyncKeyState(vbKeyLButton) = 0 Then
MsgBox "lasciato"
Timer3.Enabled = False
End If
End Sub



Ovviamente non funziona... il timer non si ferma e continua a scrivere "Lasciato"... avete suggerimenti?
Vorrei evitare il Timer3.Interval = 0
Grazie
aaa
09/09/09 8:50
dylan666
Mie ero incartato tra i timer attivi ela disattivazione...

Private Sub Timer2_Timer()
If GetAsyncKeyState(vbKeyLButton) = -32768 Then
'MsgBox "premuto"
Timer3.Enabled = True
Timer2.Enabled = False
End If
End Sub

Private Sub Timer3_Timer()
If GetAsyncKeyState(vbKeyLButton) = 0 Then
MsgBox "lasciato"
Timer3.Enabled = False
End If
End Sub
aaa