Method: Clipboard::Windows#paste
- Defined in:
- lib/clipboard/windows.rb
#paste(_ = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/clipboard/windows.rb', line 46 def paste(_ = nil, **) return String.new unless User32.open(nil) hclip = User32.get( CF_UNICODETEXT ) return String.new if hclip.null? pointer_to_data = Kernel32.lock( hclip ) # Windows Unicode is ended by two null bytes, so get the whole string size = Kernel32.size( hclip ) data = pointer_to_data.read_string( size - 2 ) data.force_encoding(Encoding::UTF_16LE) ensure Kernel32.unlock(hclip) if hclip && !hclip.null? User32.close end |