<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changes in using ctypes (python) for Maya 2014/2015? in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/changes-in-using-ctypes-python-for-maya-2014-2015/m-p/9198396#M14109</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I ran into the same issue and posted about it on the forum. The responses my help you: &lt;A href="https://forums.autodesk.com/t5/maya-programming/ctypes-bug-cannot-copy-data-to-clipboard-via-python/m-p/9197068/highlight/true#M10992" target="_blank"&gt;https://forums.autodesk.com/t5/maya-programming/ctypes-bug-cannot-copy-data-to-clipboard-via-python/m-p/9197068/highlight/true#M10992&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Dec 2019 11:49:14 GMT</pubDate>
    <dc:creator>mikey.n</dc:creator>
    <dc:date>2019-12-12T11:49:14Z</dc:date>
    <item>
      <title>Changes in using ctypes (python) for Maya 2014/2015?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/changes-in-using-ctypes-python-for-maya-2014-2015/m-p/5482834#M14108</link>
      <description>&lt;P&gt;I have a nice little clipboard function that I found on stackoverflow that works fine in Maya 2011&lt;SPAN&gt;. However in Maya 2015 this function is no longer&amp;nbsp;working. It doesn't throw any errors and it completely breaks my clipboard, meaning I can't copy/cut/paste text outside of Maya.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Since this code is a too dense for me, I am asking you guys if there's&amp;nbsp;been any changes I need to account for&amp;nbsp;since Maya updated python from &lt;SPAN&gt;2.6.4 to&amp;nbsp;&lt;/SPAN&gt;2.7.3 to get it working again.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;def winSetClipboard(text):
    GMEM_DDESHARE = 0x2000
    ctypes.windll.user32.OpenClipboard(None)
    ctypes.windll.user32.EmptyClipboard()
    try:
        # works on Python 2 (bytes() only takes one argument)
        hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text))+1)
    except TypeError:
        # works on Python 3 (bytes() requires an encoding)
        hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text, 'ascii'))+1)
    pchData = ctypes.windll.kernel32.GlobalLock(hCd)
    try:
        # works on Python 2 (bytes() only takes one argument)
        ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text))
    except TypeError:
        # works on Python 3 (bytes() requires an encoding)
        ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text, 'ascii'))
    ctypes.windll.kernel32.GlobalUnlock(hCd)
    ctypes.windll.user32.SetClipboardData(1,hCd)
    ctypes.windll.user32.CloseClipboard()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jan 2015 17:55:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/changes-in-using-ctypes-python-for-maya-2014-2015/m-p/5482834#M14108</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-26T17:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Changes in using ctypes (python) for Maya 2014/2015?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/changes-in-using-ctypes-python-for-maya-2014-2015/m-p/9198396#M14109</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I ran into the same issue and posted about it on the forum. The responses my help you: &lt;A href="https://forums.autodesk.com/t5/maya-programming/ctypes-bug-cannot-copy-data-to-clipboard-via-python/m-p/9197068/highlight/true#M10992" target="_blank"&gt;https://forums.autodesk.com/t5/maya-programming/ctypes-bug-cannot-copy-data-to-clipboard-via-python/m-p/9197068/highlight/true#M10992&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 11:49:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/changes-in-using-ctypes-python-for-maya-2014-2015/m-p/9198396#M14109</guid>
      <dc:creator>mikey.n</dc:creator>
      <dc:date>2019-12-12T11:49:14Z</dc:date>
    </item>
  </channel>
</rss>

