0
如何將用戶文本在其他應用程序中選擇複製到應用程序中的某個變量? 使用全局熱鍵 - 用戶單擊熱鍵,然後我的應用程序將在活動窗口中捕獲選定的文本。從窗口複製文本
如何將用戶文本在其他應用程序中選擇複製到應用程序中的某個變量? 使用全局熱鍵 - 用戶單擊熱鍵,然後我的應用程序將在活動窗口中捕獲選定的文本。從窗口複製文本
使用ClipBoard.GetText()方法
這的getText方法是具備predefind textdataformat的一個參數
public enum TextDataFormat
{
// Summary:
// Specifies that the text data is in the System.Windows.DataFormats.Text data
// format.
Text = 0,
//
// Summary:
// Specifies that the text data is in the System.Windows.DataFormats.UnicodeText
// data format.
UnicodeText = 1,
//
// Summary:
// Specifies that the text data is in the System.Windows.DataFormats.Rtf data
// format.
Rtf = 2,
//
// Summary:
// Specifies that the text data is in the System.Windows.DataFormats.Html data
// format.
Html = 3,
//
// Summary:
// Specifies that the text data is in the System.Windows.DataFormats.CommaSeparatedValue
// data format.
CommaSeparatedValue = 4,
//
// Summary:
// Specifies that the text data is in the System.Windows.DataFormats.Xaml data
// format.
Xaml = 5,
}
so if you know that data format is Text tha n
string text = ClipBoard.GetText(TextDataFormats.Text);
一種方法是使用剪貼板
爲什麼不直接使用剪貼板? – Doggett 2010-12-04 10:53:50