open exe - FindWindowsEX
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
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!
精彩评论