程序运行后等待10分钟自动点击F10,然后等待一秒按enter键再过一秒后再次按enter,再过两秒后按F12,再次等待一秒钟后还是按一下enter键,到此为一个循环完成   让这个功能循环99次。

解决方案 »

  1.   

    我给你写了段代码.把分给我.'时间计时
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    '模拟按键
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)Const VK_F10 = &H79
    Const VK_F12 = &H7B
    Const VK_RETURN = &HDConst KEYEVENTF_EXTENDEDKEY = &H1
    Const KEYEVENTF_KEYUP = &H2Dim BExit As Boolean '控制循环退出的
    '单位秒
    Public Function delay(ByRef s As Double)
    Dim t As Double
    t = Timer
    Do
        If BExit Then End
        DoEvents
        Sleep (1)
    Loop Until Timer - t > s
    End Function
    Public Function KeyEvent(ByVal KeyNum As Integer)
    keybd_event KeyNum, 0, KEYEVENTF_EXTENDEDKEY, 0
    keybd_event KeyNum, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
    End Function
    Private Sub Form_Load()
    BExit = False
    Me.Show
    Dim i As Integer '控制循环
    i = 0
    Do
        If BExit Then End
        
        delay 60 * 10
        'F10
        KeyEvent VK_F10
        
        delay 1
        'enter
        KeyEvent VK_RETURN
        
        delay 1
        'enter
        KeyEvent VK_RETURN
        
        delay 2
        'F12
        KeyEvent VK_F12
        
        delay 1
        'enter
        KeyEvent VK_RETURN
        
        i = i + 1
    Loop While i < 99 '循环99次
    End SubPrivate Sub Form_Unload(Cancel As Integer)
    BExit = True
    End Sub
      

  2.   

    http://www.autohotkey.com
      

  3.   

    应该是全局。或者对某个窗口有用吧。
    前台手动通过置顶窗体。就用sendkeys或keybd_event就可以.后台操作就用postmessage