我想做一个VB程序,让它在后台运行,并且时时刻刻监控着键盘。
例如:在正常情况下,F5的作用是刷新,我在VB程序里面改变它的作用,按下F5后就调用A.EXE。。
我想使这个VB程序在后台运行的时候,按F5键的时候,就调用A.EXE!
问高手们这个可不可以做啊,怎么做?

解决方案 »

  1.   

    做安装程序时放到 开始/程序/启动 里面。开机即运行你的程序,你的程序里打开后,即隐藏(Me.Visible = False)。
    调用A.EXE:
    Public Declare Function ShellExecute _
        Lib "shell32.dll" Alias "ShellExecuteA" _
        ( _
        ByVal hwnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long _
        ) As Long
    Call ShellExecute(Me.hwnd, "Open", App.Path + "\a.exe", "", "", 1)
      

  2.   

    '100ms的定时器  (相应API可以查询API浏览器)
    Private Sub tmrSystem_Timer()
      Dim intKey As Integer
       
      intKey = (GetAsyncKeyState(VK_F5) And &HFF00) / 2 ^ 15
      
      If intKey = -1 Then     'F5
         shell App.Path + "\a.exe" 
      End IfEnd Sub