零起點學VB做外掛(一)


最近正在玩武林外傳2,有時候太累手了,就用按鍵精靈做了個程序。結果武林外傳2居然查出來了,將號給封了一天。又不太敢down網上的外掛,誰知道那個有毒,那個有木馬。看來出路只有一條了,那就是寫自己的外掛。

自打上學的時候就不喜歡VC,看着就煩,所以只能從VB下手了。以后有合適的軟件咱再用不遲。

說干就干。咱初步的要求不高,只要能夠模擬鍵盤操作就行。從網上看了篇<用VB模擬鍵盤事件的N種方法>,咱不貪心,現從最簡單的全局級模擬開始好了。

下面就是俺的第一個程序,vb.net寫的代碼如下:
    Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal Scan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    Const KEYEVENTF_KEYUP = &H2

    Const VK_0 = 96
    Const VK_1 = 97
    Const VK_2 = 98
    Const VK_3 = 99
    Const VK_4 = 100
    Const VK_5 = 101
    Const VK_6 = 102
    Const VK_7 = 103
    Const VK_8 = 104
    Const VK_9 = 105
    Const VK_A = 65
    Const VK_B = 66
    Const VK_C = 67
    Const VK_D = 68
    Const VK_E = 69
    Const VK_F = 70
    Const VK_G = 71
    Const VK_H = 72
    Const VK_I = 73
    Const VK_J = 74
    Const VK_K = 75
    Const VK_L = 76
    Const VK_M = 77
    Const VK_N = 78
    Const VK_O = 79
    Const VK_P = 80
    Const VK_Q = 81
    Const VK_R = 82
    Const VK_S = 83
    Const VK_T = 84
    Const VK_U = 85
    Const VK_V = 86
    Const VK_W = 87
    Const VK_X = 88
    Const VK_Y = 89
    Const VK_Z = 90
    Const VK_WINDOW = 91




    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call keybd_event(VK_WINDOW, 0, 0, 0)   '按下window鍵
        Call keybd_event(VK_F, 0, 0, 0)      '按下r鍵
        Call Sleep(1000)            '延時500毫秒
        Call keybd_event(VK_F, 0, KEYEVENTF_KEYUP, 0)   '釋放r鍵
        Call keybd_event(VK_WINDOW, 0, KEYEVENTF_KEYUP, 0)   '釋放window鍵

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub

這是第一步的學習。應該都看的懂。呵呵。好,今天收工了。

 

 


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
  © 2014-2022 ITdaan.com 联系我们: