VB键盘鼠标无动作调用程序的尝试

  'API调用与常用定义:

  Private Declare Function SystemParametersInfo _

  Lib "user32" _

  Alias "SystemParametersInfoA" _

  (ByVal uiAction As Long, _

  ByVal uiParam As Long, _

  pvParam As Any, _

  ByVal fWInIni As Long) As Boolean

  Private Const SPI_GETSCREENSAVEACTIVE As Long = &H10 '屏保是否启用的常量

  Private Const SPI_GETSCREENSAVERRUNNING As Long = &H72 '屏保是否运行的常量

  Private Sub Timer1_Timer()

  Dim bRunning As Boolean '屏保是否运行的变量,当然你可以定义全局变量

  SystemParametersInfo SPI_GETSCREENSAVERRUNNING, 0, bRunning, False '调用API,bRunning返回屏保运行状态

  Debug.Print Time; "屏保运行="; bRunning '演示:打印屏保是否运行的信息

  End Sub

  '另外,查看屏保是否启用,也可以用下面方法:

  SystemParametersInfo SPI_GETSCREENSAVEACTIVE, 0, bActive, False 'bActive为返回值(逻辑型)