Program przechwytuje akcje zmiany zawartości schowka jednak po jakimś czasie od włączenia programu tak jakby gubi hooka (jeśli mogę tak to nazwać) po prostu program nie dostaje już informacji o zmianie zawartości schowka. Nie mam pojęcie co z tym zrobić, trudno jakieś poprawki wprowadzić bo nigdy nie wiadomo kiedy może przestać to działać, nieraz chodzi cały dzień i ciągle działa.
Tutaj mój kod:
[DllImport("User32.dll")]
public static extern int SetClipboardViewer(int hWndNewViewer);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
private IntPtr ClipboardViewer;
public Main()
{
InitializeComponent();
this.ClipboardViewer = (IntPtr)SetClipboardViewer((int)this.Handle);
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0308: // WM_DRAWCLIPBOARD
if (Clipboard.ContainsText())
this.UseText(Clipboard.GetText());
SendMessage(this.ClipboardViewer, m.Msg, m.WParam, m.LParam);
break;
case 0x030D: // WM_CHANGECBCHAIN
if (m.WParam == this.ClipboardViewer)
this.ClipboardViewer = m.LParam;
else
SendMessage(this.ClipboardViewer, m.Msg, m.WParam, m.LParam);
break;
}
base.WndProc(ref m);
}
public void UseText(string value)
{
}