当我最小化程序并按F9开始和停止时,我该怎么办?
我已经制作了点击器,但想要制作热键/快捷键。
我使用Visual Basic
答案 0 :(得分:0)
为此我相信你需要一个KeyLogger。我找到了一些代码here并用它来制作一个有效的例子:
Public Class Form1 ' Creates variables and functions Dim T As New Timer() With {.Enabled = True, .Interval = 1} Dim key As Integer Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Keys) As Short Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load AddHandler T.Tick, AddressOf T_Tick End Sub Private Sub T_Tick(ByVal sender As Object, ByVal e As EventArgs) For i = 1 To 255 key = 0 key = GetAsyncKeyState(i) ' If this key is being pressed If key = -32767 Then ' Writes the key that was pressed Console.WriteLine(Chr(i)) If i = 120 Then ' This happens when F9 is pressed End If End If Next i End Sub End Class
希望这有帮助! 〜尼克
答案 1 :(得分:0)
您可以在表单加载中添加KeyPreview = True
后执行此操作
添加一个名为keydown的事件并添加以下代码:
If e.keycode = Keys.F9 Then
Button1.PerformClick()
End If