-dt-
Scripting Contest Winner
;o
Posts: 1819 Reputation: 74
36 / /
Joined: Mar 2004
|
RE: [UPDATED] Clipboard Functions (that WORK)
try this
code: function readClipboard() {
var CF_TEXT = 1;
var CF_OEMTEXT = 7;
var CF_UNICODETEXT = 13;
var toBeReturned = false;
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.Allocate(size+2);
Interop.Call("Kernel32", "RtlMoveMemory", str, pchData, size);
toBeReturned = str.ReadString(0);
var unlocked = Interop.Call("Kernel32", "GlobalUnlock", hClipboardData);
} else {
Interop.Call("User32", "CloseClipboard");
return false;
}
Interop.Call("User32", "CloseClipboard");
}
} catch(ex) {
Interop.Call("User32", "CloseClipboard");
return false;
}
return toBeReturned;
}
Happy Birthday, WDZ
|
|