の取得は、私はJSでクリップボードのテキストを取得しようとするものである:UWP:ここでクリップボードのテキスト
function getClipboard() {
var content = Windows.ApplicationModel.DataTransfer.Clipboard.getContent();
if (content.contains(Windows.System.string)) {
var text = content.getTextAsync(Windows.System.string);
$('section#show-clipboard #textarea').text(text);
} else {};
};
私はClipboard.getContent()とDataPackageView.getTextAsync(Windows.System.String)メソッドを使用しています。
興味深いのは、それは私がクリップボードにコピーどのくらいのテキスト問題ではありません、それは常にcontent.contains(Windows.System.string)
がfalse
に等しいことを言うだろうとcontent.getTextAsync(Windows.System.string);
の例外が表示されますことをこれは例外です:
0x8004006a - JavaScript runtime error: Invalid clipboard format
DataPackage does not contain the specified format. Verify its presence using DataPackageView.Contains or DataPackageView.AvailableFormats. WinRT information: DataPackage does not contain the specified format. Verify its presence using DataPackageView.Contains or DataPackageView.AvailableFormats.
あなたは正しいと思います。少なくともDataPckageViewはif文を渡します。しかし、 'JSON.stringify(content.getTextAsync(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text))'が返すオブジェクトは '{" operation ":{}}'です。それは意味をなさない... – jonhue
GetTextAsyncは非同期であり、実際のテキストではなくJavaScriptの約束を返します。実行方法については、https://docs.microsoft.com/en-us/windows/uwp/threading-async/asynchronous-programming-universal-windows-platform-apps#asynchronous-patterns-in-uwp-using-javascriptを参照してください。それ。 –