1. Import the API function FindWindowex to find the bubble chat window, use SPY to find the class name of the bubble chat.
2. Import the API function showWindow to activate the found bubble window.
Related code:
public class NativeWIN32 {[DllImport ( "user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr FindWindowEx (IntPtr parent / * HWND * /, IntPtr next / * HWND * /, string sClassName, IntPtr sWindowTitle); [ DLLIMPORT ("User32.dll", Charset = charset.auto)] Public Static Extern Void SetForeGroup;
[DllImport ( "user32.dll")] public static extern bool ShowWindow (int hWnd, nCmdShow nCmdShow); public enum nCmdShow: uint {SW_FORCEMINIMIZE = 0x0, SW_HIDE = 0x1, SW_MAXIMIZE = 0x2, SW_MINIMIZE = 0x3, SW_RESTORE = 0x4, SW_SHOW = 0x5, sw_showdefault = 0x6, sw_showmaximized = 0x7, sw_showminimized = 0x8, sw_showminnoactive = 0x9, sw_showna = 0xa, sw_shownoactivate = 0xb, sw_shownormal = 0xc,}
}
3. Send a reply information to the activated bubble chat window with the System.Windows.Forms.sendKeys.send method.
4. Use the System.Windows.Forms.sendKeys.send method to send Alt F4 to the activated bubble chat window, turn off the window.
(This method is not good, easy to close other programs, change to call API SendMessage, 2004-7-26
Import API:
[DLLIMPORT ("User32.dll", Charset = Charset.Auto)] Public Static Extern Int SendMessage (INTPTR HWND, INT MSG, INT WPARAM, INT LPARAM);
transfer:
SendMessage (HNEXT, 0x0010, 0, 0); // HNext is the window handle, 0x0010 is the value of the message WM_CLOSE. )
Related code:
private void timer1_Tick (object sender, System.EventArgs e) {IntPtr hParent = IntPtr.Zero; string sClassNameFilter = "NETEASE POPO UniformMsgWnd"; // all category string strMsg POPO chat window; strMsg = tbMsg.Text; hNext = NativeWIN32. FindWindowEx (hParent, hNext, sClassNameFilter, IntPtr.Zero); // Get the window handle if (hNext.ToInt32 ()> 0) {NativeWIN32.ShowWindow (hNext.ToInt32 (), NativeWIN32.nCmdShow.SW_SHOWMINNOACTIVE); // display window System.windows.Forms.sendKeys.send (strmsg "{entry}); system.windows.forms.sendKeys.send (" {enter} {enter} {enter} {enter} {enter} {enter} {enter} {enter} {enter} "); // Because the input method is turned on because the Send method sends characters, it will cause the focus to disorder, so add a few carriages, for the bubble chat window, the empty return window does not respond. System.windows.Forms.sendKeys.send ("% {f4}");}}