将文本添加到另一个程序文本框C ++ [英] adding text to another programs text box c++

查看:53
本文介绍了将文本添加到另一个程序文本框C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设法将文本发送到我使用c ++创建的自定义文本框,并发送到带有1个窗口和1个文本框的记事本,calc和其他程序.但是,我想将文本发送到另一个程序,该程序具有多个文本框,并且也位于选项卡中.它的结构如下:

i have already managed to send text to a custom text box i created using c++, and to notepad, calc and other programs all with 1 window and 1 text box. however, i want to send text to another program that has more than one text box and is in tabs too. it is structured like so:

  1. 打开程序
  2. 从2个选项卡中选择:统计b.config(包含文本框)
  3. 在4个文本框中填写所需的值

我没有运气就尝试过winspy ++,这是我一直在使用的简单代码.

i have tried winspy++ with no luck, here is simple code i have been working with.

#include <windows.h>

int main()
{ 
HWND hNote;
HWND hChild;

if (!(hNote=FindWindow("windowname",NULL)))
    exit(1);

if (!(hChild=FindWindowEx(hNote,NULL,"EDIT",NULL)))
    exit(2);

SendMessage(hChild,WM_SETTEXT,NULL,(LPARAM)"texttoadd");

return 0;
}

任何人都可以帮我解决这个问题吗?

Can anyone help me how can resolve this issue ?

推荐答案

所以问题是要获取特定控件的句柄.例如,您可以使用以下方法查找控件的句柄:

So the problem is to get a handle of the specific control. You may use for example following ways for finding control's handle:

  • Control can be distinguished by control id, then use GetDlgItem function to get the its handle. Control id can be found using tools like Spy++ or InqSoft Windows Scanner or other.
  • MSDN says that control can be found by coordinates of the point within parent window by ChildWindowFromPoint , ChildWindowFromPointEx or RealChildWindowFromPoint function.
  • Or all controls can be enumerated within parent window by EnumChildWindows and an appropriate one can be found using custom rules.

这篇关于将文本添加到另一个程序文本框C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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