打开 exe - FindWindowsEX

发布于 2024-10-29 20:51:04 字数 743 浏览 2 评论 0原文

我正在运行一个能够处理 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

著墨染雨君画夕 2024-11-05 20:51:04

那么,您无法使用这些技术访问控件的名称。我要做的就是重写 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文