protected override void WndProc(ref Message m) { if (m.Msg == 74) { Type type = new MessageHelper.COPYDATASTRUCT().GetType(); MessageHelper.COPYDATASTRUCT copydatastruct = (MessageHelper.COPYDATASTRUCT)m.GetLParam(type); try { IntPtr num = new IntPtr(m.WParam.ToInt32()); string str = string.Copy(copydatastruct.lpData); foreach (D2Profile pro in HandlerClass.Instance.bpro) { if (pro.D2Process.MainWindowHandle == pro.D2Process.MainWindowHandle)//Cheking For the real Window so its not wrong one! This fix will allow more clients! HandlerClass.Instance.HandleMessage(num, str); } } catch { } m.Result = (IntPtr)1; } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == 0x00A3) //disable maximize on doubleclick { m.Result = IntPtr.Zero; return; } if (m.Msg == 0x0084 /*WM_NCHITTEST*/) { m.Result = (IntPtr)2; //HTCLIENT return; } switch (m.Msg) { case MessageHelper.WM_USER: MessageBox.Show("Message recieved: " + m.WParam + " - " + m.LParam); break; case MessageHelper.WM_COPYDATA: MessageHelper.COPYDATASTRUCT mystr = new MessageHelper.COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (MessageHelper.COPYDATASTRUCT)m.GetLParam(mytype); viribot.Say(mystr.lpData); break; } base.WndProc(ref m); }
public static bool SendTimeout(IntPtr hWnd, string msg, IntPtr id, int delay = 0, int retry = 1) { byte[] bytes = Encoding.UTF8.GetBytes(msg + "\0"); MessageHelper.COPYDATASTRUCT lParam = new MessageHelper.COPYDATASTRUCT() { dwData = id, cbData = bytes.Length, lpData = Marshal.AllocHGlobal(bytes.Length) }; Marshal.Copy(bytes, 0, lParam.lpData, bytes.Length); for (int index = 0; index < retry; ++index) { if (delay > 0) { Thread.Sleep(delay); } IntPtr result; MessageHelper.SendMessageTimeout(hWnd, 74U, IntPtr.Zero, ref lParam, MessageHelper.SendMessageTimeoutFlags.SMTO_NOTIMEOUTIFNOTHUNG, 1000U, out result); if (result != IntPtr.Zero) { return(true); } } return(false); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case MessageHelper.WM_COPYDATA: MessageHelper.COPYDATASTRUCT copyDataStruct = new MessageHelper.COPYDATASTRUCT(); Type copyDataType = copyDataStruct.GetType(); copyDataStruct = (MessageHelper.COPYDATASTRUCT)m.GetLParam(copyDataType); if (copyDataStruct.lpData.Equals("ProfilesImported")) { RefreshAll(); } break; } base.WndProc(ref m); }