C#里如何实现每5分钟按一下"V"键,API函数keydb_event要怎么实现啊?

解决方案 »

  1.   

    //参考如下代码:
            [DllImport("user32.dll")]
            public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
            public const uint KEYEVENTF_KEYUP = 2;
            private void timer1_Tick(object sender, EventArgs e)
            {
                keybd_event((byte)'V', 0, 0, 0);
                keybd_event((byte)'V', 0, KEYEVENTF_KEYUP, 0);
            }
      

  2.   

    我是新手啊!下面的调试通不过啊.
    using System;
    using System.Runtime.InteropServices;
    main class key1 {
      [DllImport("user32.dll")]
            public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
            public const uint KEYEVENTF_KEYUP = 2;
            private void timer1_Tick(object sender, EventArgs e)
            {
                keybd_event((byte)'V', 0, 0, 0);
                keybd_event((byte)'V', 0, KEYEVENTF_KEYUP, 0);
            }
    }
      

  3.   

    那你就用1楼的
    SendKeys.Send("v");
    更方便
      

  4.   

    放个Timer,tick设为5分钟,再用SendKeys.Send("V");
      

  5.   

    放个Timer,tick设为5分钟,再用SendKeys.Send("V");--------------这个正确,简单实用