This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Putting text in clipboard
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Aug 15, 2011
07:50 AM
Putting text in clipboard
Hi
I am trying (unsuccessfully) to copy some text to the clipboard.
has anyone succeeded in doing so?
This is as far as I got:
From my logs I see that pLockedStr gets the proper value, but somehow when I press the ctrl+v I get nothing. (previous content of clipboard got deleted.)
I am trying (unsuccessfully) to copy some text to the clipboard.
has anyone succeeded in doing so?
This is as far as I got:
// prototypes for the clipboard actions
prototype copyTextToClipboard(string );
prototype NUMBER User32.CloseClipboard();
prototype NUMBER User32.OpenClipboard(BYVAL NUMBER);
prototype NUMBER User32.SetClipboardData(NUMBER, NUMBER);
prototype STRING Kernel32.GlobalLock ( NUMBER );
prototype NUMBER Kernel32.GlobalUnlock(HWND);
prototype NUMBER Kernel32.GlobalAlloc ( NUMBER, NUMBER );
#define GMEM_MOVEABLE 0x0002
#define GMEM_ZEROINIT 0x0040
#define GHND (GMEM_MOVEABLE | GMEM_ZEROINIT)
#define CF_UNICODETEXT 13
// use win32 api to copy the given string to the clipboard.
function copyTextToClipboard(str)
NUMBER hClipboardData;
STRING pLockedStr;
string test;
begin
if (User32.OpenClipboard(NULL) != 0) then
hClipboardData = Kernel32.GlobalAlloc(GHND, StrLength(str)+2); // added +2 for the null that AFAIK might be UTF-16
//Lock Clipboard, getting pointer to actual data.
pLockedStr = Kernel32.GlobalLock(hClipboardData);
CopyBytes(pLockedStr,0, str, 0, StrLength(str));
Kernel32.GlobalUnlock(hClipboardData);
User32.SetClipboardData(CF_UNICODETEXT, hClipboardData);
User32.CloseClipboard();
AskText("Paste here to check if paste to clipboard works...", "", test);
endif;
end;
From my logs I see that pLockedStr gets the proper value, but somehow when I press the ctrl+v I get nothing. (previous content of clipboard got deleted.)
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
May 09, 2016
05:50 PM
try to make pLockedString a pointer and use lstrcopy from kernel32 to copy the data in.
prototype POINTER Kernel32.lstrcpy( POINTER, POINTER );
function...
POINTER pLockedStr, pstr;
begin
...
//CopyBytes(pLockedStr,0, str, 0, StrLength(str));
pstr = &str;
lstrcpy( pLockedString , pstr );
Kernel32.GlobalUnlock(hClipboardData);
User32.SetClipboardData(CF_TEXT, hClipboardData);
User32.CloseClipboard();
prototype POINTER Kernel32.lstrcpy( POINTER, POINTER );
function...
POINTER pLockedStr, pstr;
begin
...
//CopyBytes(pLockedStr,0, str, 0, StrLength(str));
pstr = &str;
lstrcpy( pLockedString , pstr );
Kernel32.GlobalUnlock(hClipboardData);
User32.SetClipboardData(CF_TEXT, hClipboardData);
User32.CloseClipboard();
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)