本文介绍了如何编写和C#/ Win32的文本发送到mIRC的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在先前的问题,我问。它帮助我极大。对于第2部分,这里的相同应用mIRC的一个简化版本:

In a previous question, I asked how to send text to Notepad. It helped me immensely. For part 2, here's a simplified version of the same applied mIRC:

[DllImport("User32.dll", EntryPoint = "FindWindow")]
public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);

IntPtr mainHandle = FindWindow("mIRC", null);
IntPtr serverHandle = FindWindowEx(mainHandle, new IntPtr(0), "MDIClient", null);
IntPtr chanHandle = FindWindowEx(serverHandle, new IntPtr(0), "mIRC_Channel", null);
IntPtr editHandle = FindWindowEx(chanHandle, new IntPtr(0), "Edit", null);

SendMessage(editHandle, 0x000C, 0, textBox1.Text);

这似乎是正确的我,但它不工作!难道窗口名称是不正确的(MDICLIENT,mIRC_Channel和编辑)?这是我在一个网站上发现通过谷歌搜索FindWindowEx mIRC的值。

This seems correct to me, except that it doesn't work! Is it that the window names are incorrect (MDIClient, mIRC_Channel, and Edit)? These are values I found on a web site by googling "FindWindowEx mIRC".

1。)我在做什么错在上面?

1.) What am I doing wrong in the above?

2。)作为参考,一般是有一个简单的方法来找到所有使用窗口名称以 FindWindowEx()

2.) For reference, in general is there an easy way to find all the Window names for use with FindWindowEx()?

推荐答案

此代码对我的作品(mIRC的6.31):

This code works for me (mirc 6.31):

IntPtr mainHandle = FindWindow("mIRC", null);
IntPtr serverHandle = FindWindowEx(mainHandle, new IntPtr(0), "MDIClient", null);  
IntPtr chanHandle = FindWindowEx(serverHandle, new IntPtr(0), "mIRC_Channel", null);  
IntPtr editHandle = FindWindowEx(chanHandle, new IntPtr(0), "richEdit20A", null);
SendMessage(editHandle, 0x000C, 0, "Hello World");



注意,改变后的窗口类(richedit20A而不是编辑)。仅通过使用间谍++找到正确的类

Notice the changed window class (richedit20A instead of edit). Just found the correct class by using Spy++.

至于窗口句柄,一种可能性是使用或的 API。

As for the window handles, one possibility is to use the EnumWindows or EnumChildWindows API.

这篇关于如何编写和C#/ Win32的文本发送到mIRC的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:29