コード例 #1
0
        /// <summary>
        /// 模拟键盘组合键
        /// </summary>
        static void SimulationKeyBoard2()
        {
            Thread.Sleep(2000);

            WinApi.keybd_event(VBKEY.vbKeyShift, 0, 0, 0);

            for (var i = 0; i < 10; i++)
            {
                #region 测试通过
                //WinApi.keybd_event(VBKEY.vbKeyA, 0, 0, 0);
                //WinApi.keybd_event(VBKEY.vbKeyA, 0, 2, 0);

                //WinApi.keybd_event(VBKEY.vbKeyB, 0, 0, 0);
                //WinApi.keybd_event(VBKEY.vbKeyB, 0, 2, 0);

                //WinApi.keybd_event(VBKEY.vbKeyTab, 0, 0, 0);
                //WinApi.keybd_event(VBKEY.vbKeyTab, 0, 2, 0);
                #endregion


                Thread.Sleep(1000);
            }

            WinApi.keybd_event(VBKEY.vbKeyShift, 0, 2, 0);
        }
コード例 #2
0
 /// <summary>
 /// 模拟键盘操作
 /// </summary>
 static void SimulationKeyBoard()
 {
     WinApi.keybd_event(Keys.Shift, 0, 0, 0);
     Thread.Sleep(500);
     WinApi.keybd_event(Keys.A, 0, 0, 0);
     Thread.Sleep(500);
     WinApi.keybd_event(Keys.B, 0, 0, 0);
     Thread.Sleep(500);
     WinApi.keybd_event(Keys.C, 0, 0, 0);
     Thread.Sleep(500);
     WinApi.keybd_event(Keys.Shift, 0, 2, 0);
 }
コード例 #3
0
        /// <summary>
        /// 从剪切板获取截图--需要设置[STAThread]属性
        /// </summary>
        static void GetImagFromClipBoard()
        {
            try
            {
                Thread.Sleep(6000);
                WinApi.keybd_event(44, 0, 0, 0);
                var img = System.Windows.Forms.Clipboard.GetImage();

                //var text = Clipboard.GetText();
                if (img == null)
                {
                    Console.WriteLine("fail screen img is null..");
                    return;
                }
                img.Save($"{DateTime.Now:yyyyMMddhhmmss}.png");
                Console.WriteLine("success...");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #4
0
 public static void SetTab()
 {
     Thread.Sleep(500);
     WinApi.keybd_event(Keys.Tab, 0, 0, 0);
     Thread.Sleep(500);
 }