This is a static archive of the Python wiki, which was retired in February 2026 due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

Asking for Help: ...

...

I was trying to use ctypes to get Windows clipboard contents and the value that gets returned is a ctypes.c_char_p string. When I print it the string looks like b'contents_of_clipboard'. I am not sure why this happens or how to get rid of it. anyone know. The code that I pilfered from the net to do this is below

   1 import ctypes, sys
   2 
   3 def winGetClipboard():
   4         ctypes.windll.user32.OpenClipboard(0)
   5         pcontents = ctypes.windll.user32.GetClipboardData(1) # 1 is CF_TEXT
   6         data = ctypes.c_char_p(pcontents).value
   7         ctypes.windll.user32.CloseClipboard()
   8         return data

If I had Hello World on the clipboard the returned output would be b'Hello World'

When answering questions, add the CategoryAskingForHelpAnswered category when saving the page. This will move the link to this page from the questions section to the answers section on the Asking for Help page.


CategoryAskingForHelp


2026-02-14 16:06