Search code examples
pythonamazon-web-serviceswindowclipboardpywin32

Amazon Virtual Desktop: python script unable to fetch Clipboard : Access denied


Amazon Virtual Desktop,

Python Script doing good stuff But unable to access data from clipboard

We have no access for C Drive and available D drive for users data

Trying the following snippet :-

import win32clipboard

# get clipboard data
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
print data

Gives me following error :-

win32clipboard.OpenClipboard() pywintypes.error: (5, 'OpenClipboard', 'Access is denied.')

Any work around or solution for it ??


Solution

  • Have a look at : https://wiki.python.org/moin/TkInter

    #from Tkinter import Tk    # Python v2.x
    from tkinter import Tk    # Python v3.x
    tkint = Tk()
    copied_val = tkint.clipboard_get()