What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » scripts and the clipboard

scripts and the clipboard
Author: Message:
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: scripts and the clipboard
@segosa, i got it to copy the first character :P

Here's how to read from the clipboard (h) (i cant believe i figured this out :O):
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.

This post was edited on 07-11-2006 at 09:07 PM by deAd.
07-11-2006 08:41 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
scripts and the clipboard - by andrey on 07-11-2006 at 05:29 AM
RE: scripts and the clipboard - by J-Thread on 07-11-2006 at 07:13 AM
RE: scripts and the clipboard - by segosa on 07-11-2006 at 08:21 AM
RE: RE: scripts and the clipboard - by andrey on 07-11-2006 at 08:01 PM
RE: scripts and the clipboard - by Ezra on 07-11-2006 at 08:16 PM
RE: scripts and the clipboard - by deAd on 07-11-2006 at 08:41 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On