樓上真殘忍,人家就問一個作用與宣告,你給寫這麼多東西。GetAsynckeystate這個函式主要是用來監測鍵盤上某個鍵是否被按下的,另外,你把拼寫錯了,少寫個C。宣告:private Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer用法(新增一個時鐘控制元件,然後把下面的程式碼全複製到VB中試試):Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As IntegerPrivate Sub Form_Load()Timer1.Interval = 100Set yz = Me.Controls.Add("vb.label", "label1")With yz .AutoSize = True .FontSize = 20 .Caption = "注意:按下S鍵測試監測效果" .Visible = TrueEnd WithEnd SubPrivate Sub timer1_timer()If GetAsyncKeyState(vbKeyS) Then Shell "mspaint", vbMaximizedFocusEnd Sub
樓上真殘忍,人家就問一個作用與宣告,你給寫這麼多東西。GetAsynckeystate這個函式主要是用來監測鍵盤上某個鍵是否被按下的,另外,你把拼寫錯了,少寫個C。宣告:private Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer用法(新增一個時鐘控制元件,然後把下面的程式碼全複製到VB中試試):Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As IntegerPrivate Sub Form_Load()Timer1.Interval = 100Set yz = Me.Controls.Add("vb.label", "label1")With yz .AutoSize = True .FontSize = 20 .Caption = "注意:按下S鍵測試監測效果" .Visible = TrueEnd WithEnd SubPrivate Sub timer1_timer()If GetAsyncKeyState(vbKeyS) Then Shell "mspaint", vbMaximizedFocusEnd Sub