为第三方WPF应用程序的TextBox控件设置文本 [英] Set text for a TextBox control of a third party WPF application

查看:230
本文介绍了为第三方WPF应用程序的TextBox控件设置文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我打算在.Net(C#)中编写一个应用程序,该应用程序使用一些键盘快捷键为第三方应用程序的任何文本区域设置一些特殊的文本.
我使用SendKeys类的Send()方法尝试了此操作,但是当我的快捷键是Ctrl/Alt键和键盘上的另一个键的组合时,会出现问题:当用户按下快捷键组合时,因为按住Ctrl/Alt键,通过Send()方法与Ctrl结合发送字符,结果不是将文本写入文本区域,而是执行一些命令.

因此,我切换到一种新方法,并通过WM_SETTEXT消息使用了SendMessage API,直到在WPF应用程序上测试我的应用程序之前,一切看起来都很好.
为了使用WPF结构,TextBox和这些窗体上的所有其他控件没有任何可用于发送消息的句柄.
有解决方案吗?

Hi,
I intend to write an application in .Net (C#) that sets some special text for any text area of third party applications using some keyboard shortcuts.
I tried this using Send() method of SendKeys class, but problem occurs when my shortcut key is a combination of Ctrl/Alt key(s) and another key on the keyboard: When user presses the shortcut key combination, because of holding Ctrl/Alt key, the characters are sent by Send() method combine with Ctrl and result is not writing text into the text area, but doing some command.

So, I switched to a new approach and used SendMessage API using WM_SETTEXT message and everything looked good until I test my application on a WPF application.

In order to WPF structure, TextBox and all other controls on these forms have not any handle that I can use for sending messages.
Is there a solution ?

推荐答案

首先,这是使用C#和VB.NET示例在.NET 1.x中的表单之间传递值
First, This is link for SendKeys.Send Method I think that be good for clear understanding it.

Then you can see this useful link Passing Values between Forms in .NET 1.x with C# and VB.NET examples


这篇关于为第三方WPF应用程序的TextBox控件设置文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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