コード例 #1
0
 public static WinHandle SendKey(this WinHandle win, char c)
 {
     if (NtApi.GetForegroundWindow() != win.Handle)
     {
         NtApi.SetForegroundWindow(win.Handle);
     }
     WinSendKeys.SendWait(c.ToString());
     return(win);
 }
コード例 #2
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            if (!((sender as Image)?.Source is BitmapImage thumbImage))
            {
                return;
            }

            var buf = Clipboard.GetDataObject();

            var target = GetBitmapImage(thumbImage.UriSource.LocalPath);

            Clipboard.SetImage(target);

            SendKeys.SendWait("^v");

            Thread.Sleep(1000);

            if (buf != null)
            {
                Clipboard.SetDataObject(buf);
            }
        }
コード例 #3
0
        public static WinHandle SendKeys(this WinHandle win, string text, bool sendCharbyChar = false,
                                         int interval = 10)
        {
            if (sendCharbyChar)
            {
                foreach (var c in text)
                {
                    Thread.Sleep(interval);
                    win.SendKey(c);
                }
            }
            else
            {
                if (NtApi.GetForegroundWindow() != win.Handle)
                {
                    NtApi.SetForegroundWindow(win.Handle);
                }
                WinSendKeys.SendWait(text);
            }

            return(win);
        }
コード例 #4
0
 public static void SendKeys(string key)
 {
     SendKeysClass.SendWait(key);
 }