发送文本到其他应用程序 [英] Send Text to other Applications

查看:69
本文介绍了发送文本到其他应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串变量。现在,我想在不使用剪贴板的情况下将字符串值存储到另一个应用程序的控件中。我想手动执行。

I have a string variable. Now i want to store a string value into a control in another application without using the clipboard. I wanna do it manually.

我认为我应该使用SendMessage(WM_SETTEXT)。您建议哪种方式(请举个例子)?

I think i should use SendMessage(WM_SETTEXT). Which way do you suggest (with an example please)?

推荐答案

因为您的应用程序知道它必须发送的字符串...

As your application knows the string it has to send...

如果需要,可以将焦点设置到目标窗口/应用程序。

You can set the focus to the target window/application if needed.

然后您处理每个包含的字符在字符串中模拟他们的击键。像这样的东西(太基本了,无法完全按照您的预期工作,但是这个主意在这里...; o)):

Then you process each char contained in your string to simulate their key strokes. Something like that (too basic to work exactly as you expect, but the idea is here... ;o)):

for i := 1 to Length(yourstring) do
begin
  keybd_event(Ord(yourstring[i]), 0, 0, 0);  // key down
  Sleep(10);
  keybd_event(Ord(yourstring[i]), 0, 0 or KEYEVENTF_KEYUP, 0); / key up
  Sleep(10);
end;

如果字符串是大写,...,则需要模拟移位,ctrl,...

If your string uppercase, ..., you need to simulate the shift, ctrl, ...

这篇关于发送文本到其他应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆