Browse Source

fixes for windows and python3

Oz N Tiram 8 years ago
parent
commit
095532196d
1 changed files with 4 additions and 3 deletions
  1. 4 3
      pwman/ui/win.py

+ 4 - 3
pwman/ui/win.py

@@ -67,15 +67,16 @@ def winGetClipboard():
 
 
 def winSetClipboard(text):
+    
     GMEM_DDESHARE = 0x2000
     ctypes.windll.user32.OpenClipboard(0)
     ctypes.windll.user32.EmptyClipboard()
     hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE,
-                                                 len(bytes(text, 'ascii'))+1)
+                                                 len(bytes(text))+1)
     pchData = ctypes.windll.kernel32.GlobalLock(hCd)
+        
+    ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text))
     
-    ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData),
-                              text.decode())
     ctypes.windll.kernel32.GlobalUnlock(hCd)
     ctypes.windll.user32.SetClipboardData(1, hCd)
     ctypes.windll.user32.CloseClipboard()