public string GetText(TextDataFormat format) { ClipboardAsync instance = new ClipboardAsync(); Thread staThread = new Thread(instance._thGetText); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(format); staThread.Join(); return instance._GetText; }
public bool ContainsText(object format) { ClipboardAsync instance = new ClipboardAsync(); Thread staThread = new Thread(instance._thContainsFileDropList); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(format); staThread.Join(); return instance._ContainsText; }
public System.Collections.Specialized.StringCollection GetFileDropList() { ClipboardAsync instance = new ClipboardAsync(); Thread staThread = new Thread(instance._thGetFileDropList); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(); staThread.Join(); return instance._GetFileDropList; }
/// <summary> /// gets the selected text from the window and have it in soe static classes. /// </summary> private void getSaveText() { StringBuilder builder = new StringBuilder(500); int foregroundWindowHandle = GetForegroundWindow(); uint remoteThreadId = GetWindowThreadProcessId(foregroundWindowHandle, 0); uint currentThreadId = GetCurrentThreadId(); //AttachTrheadInput is needed so we can get the handle of a focused window in another app AttachThreadInput(remoteThreadId, currentThreadId, true); //Get the handle of a focused window int focused = GetFocus(); //Now detach since we got the focused handle AttachThreadInput(remoteThreadId, currentThreadId, false); //Get the text from the active window into the stringbuilder SendMessage(focused, WM_COPYTEXT, builder.Capacity, builder); ClipboardAsync clip = new ClipboardAsync(); globalValue.textCopied = clip.GetText(TextDataFormat.Html); }