Copy to, or get from Windows Clipboard
From NSIS Wiki
Jump to navigationJump to search
Author: Afrow UK (talk, contrib) |
Description
Here are two scripts which you may find helpful...
Copy string to Windows Clipboard
Usage
Push "hello" ;input > copy to clipboard Call CopyToClipboard
The Function
Function CopyToClipboard Exch $0 ;input string Push $1 Push $2 System::Call 'user32::OpenClipboard(i 0)' System::Call 'user32::EmptyClipboard()' StrLen $1 $0 IntOp $1 $1 + 1 System::Call 'kernel32::GlobalAlloc(i 2, i r1) i.r1' System::Call 'kernel32::GlobalLock(i r1) i.r2' System::Call 'kernel32::lstrcpyA(i r2, t r0)' System::Call 'kernel32::GlobalUnlock(i r1)' System::Call 'user32::SetClipboardData(i 1, i r1)' System::Call 'user32::CloseClipboard()' Pop $2 Pop $1 Pop $0 FunctionEnd
Copy string from Windows Clipboard
Usage
Call CopyFromClipboard Pop $0 ;output > copied from clipboard
The Function (ANSI)
Function CopyFromClipboard Push $0 System::Call 'user32::OpenClipboard(i 0)' System::Call 'user32::GetClipboardData(i 1) t .r0' System::Call 'user32::CloseClipboard()' Exch $0 FunctionEnd
The Function (Unicode)
Function CopyFromClipboard Push $0 System::Call 'user32::OpenClipboard(i 0)' System::Call 'user32::GetClipboardData(i 13) w .r0' System::Call 'user32::CloseClipboard()' Exch $0 FunctionEnd
Thanks Kichik and Brainsucker for getting these solutions.
-Stu :)