|
|
a warm hello to all msn gurus
hi i am trying to develop a badword filter for msn/messenger to help protect my kids from bad words... "yes those words ...that later i we have to make up a fake definition when they ask dad what is the meaning of f**k :x"
anyways, i started using winpcap to capture the incoming socket but later found out that since sp2 xp will not allowed this"
the big question:
while reading this article it came to my attention that maybe i could filter at the application level....
do you think if taking this/your aproche would eventually end up in a simple badword_filter.dll.
thanks
Ivo Gomez
http://ivogomez.com
<br><br>
|
|
|
|
|
I understand your use of this function, but it might lead to errors.
You pin the object, get the address, and then free the handle before returning the function. If unlucky the garbage collector runs before your SendMessage code, and it will fail.
You need to keep your objects pinned until you're done with the pinvoke.
|
|
|
|
|
Hi !
Does the program compatible with Live Messenger 2009 ? I tried to execute it with 2009 version and it seems has no effect : the personal message is not set.
Alain.
|
|
|
|
|
I realy enjoy this code, Finally i can display when im Out/Sleeping/Working.
I would just like to know if it is at all posible to add more icons

|
|
|
|
|
I CAN'T ET THIS DAMMED THING 2 WORK, THE FIRST TIME I TRIED IT WORKED BUT WHEN I ACCIDENTLY CLOSED IT AND OPPENED IT AGAIN (AND PASTED MY TEXT!) AND PRESSED START IT WOULDN'T WORK! wHATS MORE, IF I PRESS STOP IT DOSEN'T PICK UP WHAT YOU LISTENING TO!
pLZ pLZ HELP!!!!!
๓єรร ฬเtђ tђє ๒єรt, ๔เє lเкє tђє гєรt.------ωнαт α ѕнαмє...ℓσσкѕ ℓιкє тнє υgℓу ƒαιяу кιѕѕє∂ уσυ ση вσтн ¢нєєкѕ!-Iт ιѕ вєттєя тσ ѕтαу ѕιℓєηт αη∂ вє тнσυgнт α ƒσσℓ, тнαη тσ σρєη σηє’ѕ мσυтн αη∂ яємσνє αℓℓ ∂συвт.
|
|
|
|
|
can you translate this into vb.net?
great app
|
|
|
|
|
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Runtime.InteropServices
Namespace MsnFloatingText
Public Class MsnFloatingTextForm
Inherits System.Windows.Forms.Form
Private txtText As System.Windows.Forms.TextBox
Private btnAction As System.Windows.Forms.Button
Private label1 As System.Windows.Forms.Label
Private btnLTR As System.Windows.Forms.RadioButton
Private btnRTL As System.Windows.Forms.RadioButton
Private btnAbout As System.Windows.Forms.Button
Private cbIcon As System.Windows.Forms.ComboBox
Private timer1 As System.Windows.Forms.Timer
Private numericUpDown1 As System.Windows.Forms.NumericUpDown
Private label2 As System.Windows.Forms.Label
Private label3 As System.Windows.Forms.Label
Private notifyIcon1 As System.Windows.Forms.NotifyIcon
Private components As System.ComponentModel.IContainer
Public Sub New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
<stathread()> _
Private Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New MsnFloatingTextForm())
End Sub
#region Variables
Private temptext As String
#endregion
#region MSN object Declaretions
<dllimport("user32", entrypoint="" :="SendMessageA" )=""> _
Private Shared Function SendMessage(ByVal Hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
<dllimport("user32", entrypoint="" :="FindWindowExA" )=""> _
Private Shared Function FindWindowEx(ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
End Function
Private Const WM_COPYDATA As Short = 74
Public Structure COPYDATASTRUCT
Public dwData As Integer
Public cbData As Integer
Public lpData As Integer
End Structure
Public data As COPYDATASTRUCT
#endregion
#region MSN Functions
Public Function VarPtr(ByVal e As Object) As Integer
Dim GC As GCHandle = GCHandle.Alloc(e, GCHandleType.Pinned)
Dim gc As Integer = GC.AddrOfPinnedObject().ToInt32()
GC.Free()
Return gc
End Function
Private Sub SendMSNMessage(ByVal enable As Boolean, ByVal category As String, ByVal message As String)
Dim buffer As String = "\0" + category + "\0" + (IIf(enable,"1","0")) + "\0{0}\0" + message + "\0\0\0\0" & Chr(0) & ""
Dim handle As Integer = 0
data.dwData = 1351
data.lpData = VarPtr(buffer)
data.cbData = buffer.Length * 2
handle = FindWindowEx(0, handle, "MsnMsgrUIManager", Nothing)
If handle > 0 Then
SendMessage(handle, WM_COPYDATA, 0, VarPtr(data))
End If
End Sub
#endregion
#region Button Events
Private Sub btnAbout_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show("FC MsnFloatingText", "About", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information)
End Sub
Private Sub btnAction_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If txtText.Text.Trim() <> "" Then
If Not timer1.Enabled Then
temptext = txtText.Text + " "
timer1.Enabled = True
btnAction.Text = "Stop"
Else
btnAction.Text = "Start"
timer1.Enabled = False
SendMSNMessage(False, "Office", "")
End If
End If
End Sub
#endregion
#region Load Form
Private Sub MsnFloatingTextForm_Load(ByVal sender As Object, ByVal e As System.EventArgs)
cbIcon.SelectedIndex = 0
End Sub
#endregion
#region TimerTick Events
Private Sub timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
If btnRTL.Checked Then
temptext = temptext.Substring(1) + temptext.Substring(0, 1)
Else
temptext = temptext.Substring(temptext.Length - 1) + temptext.Substring(0, temptext.Length - 1)
End If
SendMSNMessage(True, cbIcon.SelectedItem.ToString(), temptext)
End Sub
Private Sub numericUpDown1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs)
timer1.Interval = Convert.ToInt16(numericUpDown1.Value)
End Sub
#endregion
#region NotifyIcon Events
Private Sub MsnFloatingTextForm_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs)
Try
If Me.WindowState = FormWindowState.Minimized Then
Me.notifyIcon1.Visible = True
Me.Visible = False
End If
Catch err As Exception
MessageBox.Show(err.Message)
End Try
End Sub
Private Sub notifyIcon1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Me.Visible = True
Me.WindowState = FormWindowState.Normal
Me.notifyIcon1.Visible = False
End Sub
#endregion
End Class
End Namespace
this is the translation i made using a webpage to convert C# to vb.net but even after cleaning the code it doesnt work. please help
|
|
|
|
|
never mind. solved. i used your controls but it this code. its easy.
<stathread()> _
Private Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New Form1())
End Sub
Private temptext As String
<dllimport("user32", entrypoint:="SendMessageA" )=""> _
Private Shared Function SendMessage(ByVal Hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
<dllimport("user32", entrypoint:="FindWindowExA" )=""> _
Private Shared Function FindWindowEx(ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
End Function
Private Const WM_COPYDATA As Short = 74
Public Structure COPYDATASTRUCT
Public dwData As Integer
Public cbData As Integer
Public lpData As Integer
End Structure
Public data As COPYDATASTRUCT
Public Function VarPtr(ByVal e As Object) As Integer
Dim GC As GCHandle = GCHandle.Alloc(e, GCHandleType.Pinned)
Dim gcc As Integer = GC.AddrOfPinnedObject().ToInt32()
GC.Free()
Return gcc
End Function
Private Sub SendMSNMessage(ByVal enable As Boolean, ByVal category As String, ByVal message As String)
Dim buffer As String = "\0" + category + "\0" + (IIf(enable, "1", "0")) + "\0{0}\0" + message + "\0\0\0\0" & Chr(0) & ""
Dim handle As Integer = 0
data.dwData = 1351
data.lpData = VarPtr(buffer)
data.cbData = buffer.Length * 2
handle = FindWindowEx(0, handle, "MsnMsgrUIManager", Nothing)
If handle > 0 Then
SendMessage(handle, WM_COPYDATA, 0, VarPtr(data))
End If
End Sub
Private Sub timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer1.Tick
If btnRTL.Checked Then
temptext = temptext.Substring(1) + temptext.Substring(0, 1)
Else
temptext = temptext.Substring(temptext.Length - 1) + temptext.Substring(0, temptext.Length - 1)
End If
SendMSNMessage(True, cbIcon.SelectedItem.ToString(), temptext)
End Sub
Private Sub numericUpDown1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs)
timer1.Interval = Convert.ToInt16(numericUpDown1.Value)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cbIcon.SelectedIndex = 0
End Sub
|
|
|
|
|
How to make this program work
Help!!! Pleese (answer on msakoman@gmail.com)
Saki
|
|
|
|
|
In order to make this program run in a 64 bit system, I think we need to do some modification:
#region MSN object Declaretions
[DllImport("User32.dll", EntryPoint = "SendMessageA")]
// private static extern int SendMessage(int Hwnd, int wMsg, int wParam, int lParam);
private static extern IntPtr SendMessage(IntPtr Hwnd, uint wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("User32.dll", EntryPoint = "FindWindowExA")]
// private static extern int FindWindowEx(int hWnd1, int hWnd2, string lpsz1, string lpsz2);
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
// private const short WM_COPYDATA = 74;
private const uint WM_COPYDATA = 74;
public struct COPYDATASTRUCT
{
// public int dwData;
public IntPtr dwData;
public int cbData;
// public int lpData;
public IntPtr lpData;
}
public static COPYDATASTRUCT data;
#endregion
#region MSN Functions
// public static int VarPtr(object e)
public static IntPtr VarPtr(object e)
{
GCHandle GC = GCHandle.Alloc(e, GCHandleType.Pinned);
// int gc = GC.AddrOfPinnedObject().ToInt32();
IntPtr gc = GC.AddrOfPinnedObject();
GC.Free();
return gc;
}
public static void SendMSNMessage(bool enable, string category, string message)
{
string buffer = "\\0" + category + "\\0" + (enable ? "1" : "0") + "\\0{0}\\0" + message + "\\0\\0\\0\\0\0";
int handle = 0;
// newly added
IntPtr handlePtr = new IntPtr(handle);
// data.dwData = 0x0547;
data.dwData = (IntPtr)0x0547;
data.lpData = VarPtr(buffer);
data.cbData = buffer.Length * 2;
// handle = FindWindowEx(0, handle, "MsnMsgrUIManager", null);
handlePtr = FindWindowEx(IntPtr.Zero, handlePtr, "MsnMsgrUIManager", null);
//if (handle > 0)
if (handlePtr.ToInt32() > 0)
// SendMessage(handle, WM_COPYDATA, 0, VarPtr(data));
SendMessage(handlePtr, WM_COPYDATA, IntPtr.Zero, VarPtr(data));
}
#endregion
I've tried running the modified version with MSN Messenger 8 under Windows Vista Beta 2 and it seemed ok.
|
|
|
|
|
Hmm this edit still doesn't work for MSN 8.1 on XP x64...
|
|
|
|
|