打开 exe - FindWindowsEX
我正在运行一个能够处理 exe 文件的应用程序。使用 process.start() 和 FindWindowsEx() 我运行 exe 并向其发送 PostMessage() 。
我的exe文件是一个表单应用程序。如果我的 exe 文件中有多个文本框,并且我只想用消息填充其中一个文本框,我该怎么办?
pControl = FindWindowEx(pWnd, IntPtr.Zero, infoChild.EditFieldName, IntPtr.Zero);
while (pControl != IntPtr.Zero)
{
pControls.Add(pControl);
pControl = FindWindowEx(pWnd, pControl, infoChild.EditFieldName, IntPtr.Zero);
}
Clipboard.SetText("Message!");
foreach (IntPtr pPost in pControls)
{
{ PostMessage(pPost, (uint)WindowMessage.WM_PASTE, 0, 0); }
}
//the codei've posted automatically populates all the textboxes from my form with "Message!"
谢谢你的建议
I am running an application that has the ability to process a exe file.Using process.start() and FindWindowsEx() I run the exe and send a PostMessage() to it.
My exe file is a form application. If i have multiple textboxes in my exe file and if i would like to populate just one of these text boxes with a message what should i do?
pControl = FindWindowEx(pWnd, IntPtr.Zero, infoChild.EditFieldName, IntPtr.Zero);
while (pControl != IntPtr.Zero)
{
pControls.Add(pControl);
pControl = FindWindowEx(pWnd, pControl, infoChild.EditFieldName, IntPtr.Zero);
}
Clipboard.SetText("Message!");
foreach (IntPtr pPost in pControls)
{
{ PostMessage(pPost, (uint)WindowMessage.WM_PASTE, 0, 0); }
}
//the codei've posted automatically populates all the textboxes from my form with "Message!"
thx for advice
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么,您无法使用这些技术访问控件的名称。我要做的就是重写 exe 表单中的 WndProc 方法,让它响应 WM_USER 消息,并让它返回您想要与之通信的文本框的窗口句柄。
然后,您应该使用 SendMessage/WM_SETTEXT 使用该句柄设置文本框中的文本。一个在没有事先警告用户的情况下破坏剪贴板内容的应用程序应该从所有已知和未知的宇宙中被驱逐!
Well, you cannot access the names of your controls using these techniques. What I would do, is to override the WndProc method in you exe's form and have it respond to the WM_USER message and have it return the window handle of the textbox that you want to communicate with.
Then you should use SendMessage/WM_SETTEXT to set the text in the textbox using that handle. An app that destroys the content of the Clipboard without prior warning to the user should be banishied from all known and unknown universes!