@segosa, i got it to copy the first character
Here's how to read from the clipboard
(i cant believe i figured this out
):
code:
function readClipboard(){
var CF_TEXT = 1;
var CF_OEMTEXT = 7;
var CF_UNICODETEXT = 13;
try {
if (Interop.Call("User32", "OpenClipboard", 0)){
if (Interop.Call("User32", "IsClipboardFormatAvailable", CF_TEXT | CF_OEMTEXT)){
var hClipboardData = Interop.Call("User32", "GetClipboardData", CF_UNICODETEXT);
var pchData = Interop.Call("Kernel32", "GlobalLock", hClipboardData);
var size = Interop.Call('Kernel32','GlobalSize',hClipboardData);
var str = '';
Interop.Call('Kernel32','RtlMoveMemory',str,pchData,size);
Interop.Call("Kernel32", "GlobalUnlock", hClipboardData);
} else {
return false;
}
Interop.Call("User32", "CloseClipboard");
}
} catch(ex) {
Interop.Call("User32", "CloseClipboard");
return false;
}
return str;
}
The function will return the text. It will return false if there are any errors or if the clipboard is empty.
Do not remove the try/catch or the clipboard will not unlock and you won't be able to copy or paste anything at all.