1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Add-Type -Namespace NS -Name Clipboard -MemberDefinition @" [DllImport("user32.dll", SetLastError=true)] public static extern bool EmptyClipboard(); [DllImport("user32.dll", SetLastError=true)] public static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem); [DllImport("user32.dll", SetLastError=true)] public static extern IntPtr GetClipboardData(uint uFormat); [DllImport("user32.dll", SetLastError=true)] public static extern bool OpenClipboard(IntPtr hWndNewOwner); [DllImport("user32.dll", SetLastError=true)] public static extern bool CloseClipboard(); [DllImport("user32.dll", SetLastError=true)] public static extern uint EnumClipboardFormats(uint format); "@ # OpenClipboard: Opens the clipboard for examination and prevents other applications from modifying the clipboard content. [NS.Clipboard]::OpenClipboard([IntPtr]::Zero) | Out-Null # EmptyClipboard: Empties the clipboard and frees handles to data in the clipboard. The function then assigns ownership of the clipboard to the window that currently has the clipboard open. [NS.Clipboard]::EmptyClipboard() # CloseClipboard: Closes the clipboard. [NS.Clipboard]::CloseClipboard() | Out-Null |