如何让VB在最小化之后仍响应相关事件?
发布网友
发布时间:2024-02-25 02:39
我来回答
共2个回答
热心网友
时间:2024-04-04 21:31
qw623577789 的回答可以,但是只能在Timer事件触发的时候捕捉到A才可以,错过了就不可以了。可以用如下代码:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Resize()
If Me.WindowState = 1 Then‘窗体最小化之后就开始捕捉键A
Do While Me.WindowState = 1
If GetAsyncKeyState(vbKeyA) Then
Command1_KeyDown
End If
DoEvents
Loop
End If
End Sub
热心网友
时间:2024-04-04 21:29
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer '声明
Private Sub Form_Load()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyA) Then
Command1_KeyDown
End If
End Sub