Here is what I try to get the Clipboards text in js:
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 {};
};
I am using the Clipboard.getContent() and the DataPackageView.getTextAsync(Windows.System.String) Methods.
The interesting thing is that it does not matter how much text I copy to the clipboard, it will always say that content.contains(Windows.System.string)
equals false
and will show an exception for content.getTextAsync(Windows.System.string);
This is the exception:
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.
I think Windows.System.string as paramter is wrong try content.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)
User contributions licensed under CC BY-SA 3.0