Author Topic: Has anyone done anything with Windows Clipbaord ? clipboard-logger  (Read 2433 times)

0 Members and 1 Guest are viewing this topic.

vmars316

  • Guest
Greetings,
Has anyone done anything with Windows Clipbaord?
I would like to write a ClipBoard-Logger.
What are clipboard commands for clipboard.open, clipboard.close, clipboard.clear, clipboard.GetData, etc..?
Thanks...Vernon

Charles Pegge

  • Guest

Hi Vernon, Welcome to the forum!

This one is from examples/system/clipboard.o2bas

Code: OxygenBasic
  1.   '=============
  2.  'THE CLIPBOARD
  3.  '=============
  4.  
  5.   #include "..\..\inc\minwin.inc"
  6.  
  7.  
  8.  
  9.   '--------------------
  10.  'WRITING TO CLIPBOARD
  11.  '====================
  12.  
  13.  
  14.   'Get exclusive access to the clipboard
  15.  '=====================================
  16.  
  17.   OpenClipboard 0 'hwnd
  18.  
  19.  
  20.   'Get some data
  21.  '=============
  22.  
  23.   string s="text for the clipboard"
  24.   le=1+len s
  25.  
  26.   'Allocate a global memory object for the text.
  27.  '=============================================
  28.  
  29.   h = GlobalAlloc GMEM_MOVEABLE, le
  30.  
  31.   'Lock the handle.
  32.  '================
  33.  
  34.   k = GlobalLock h
  35.  
  36.  
  37.   'copy in the data
  38.  '================
  39.  
  40.   copy k, strptr s, le
  41.  
  42.   'Attach it to the clipboard
  43.  '==========================
  44.  
  45.   SetClipboardData CF_TEXT, h
  46.  
  47.   'Unlock the memory block
  48.  '=======================
  49.  
  50.   GlobalUnlock h
  51.  
  52.   'Release the Clipboard
  53.  '=====================
  54.  
  55.   CloseClipboard 0 'hwnd
  56.  
  57.  
  58.  
  59.   '----------------------
  60.  'READING FROM CLIPBOARD
  61.  '======================
  62.  
  63.  
  64.   'Get exclusive access to the clipboard
  65.  '=====================================
  66.  
  67.   OpenClipboard 0 'hwnd
  68.  
  69.   'get data from clipboard
  70.  '=========================
  71.  
  72.   h = GetClipboardData CF_TEXT
  73.  
  74.   'Lock the handle.
  75.  '================
  76.  
  77.   k = GlobalLock h
  78.  
  79.   'Copy it
  80.  '=======
  81.  
  82.   zstring z at k
  83.   string s=z
  84.  
  85.   'Unlock the memory block
  86.  '=======================
  87.  
  88.   GlobalUnlock h
  89.  
  90.   'Release the Clipboard
  91.  '=====================
  92.  
  93.   CloseClipboard 0 'hwnd
  94.  
  95.   'Display data
  96.  '============
  97.  
  98.   print s
  99.  

Another example can be found in projectsA/Speech/

There are quite a number of Clipboard functions available. I've only used a few of them

http://msdn.microsoft.com/en-us/library/windows/desktop/ms648709(v=vs.85).aspx

Charles

vmars316

  • Guest
This one is from examples/system/clipboard.o2bas

Ah, very cool. Thanks...Vernon