mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-29 19:31:20 -04:00
made copy to clipboard work in windows. fixes #46
This commit is contained in:
parent
8f9d43055c
commit
d8dbbcc42a
1 changed files with 16 additions and 2 deletions
|
@ -65,8 +65,22 @@ def start_onionshare():
|
||||||
|
|
||||||
@app.route("/copy_url")
|
@app.route("/copy_url")
|
||||||
def copy_url():
|
def copy_url():
|
||||||
global clipboard
|
if platform.system() == 'Windows':
|
||||||
clipboard.setText(url)
|
# Qt's QClipboard isn't working in Windows
|
||||||
|
# https://github.com/micahflee/onionshare/issues/46
|
||||||
|
import ctypes
|
||||||
|
GMEM_DDESHARE = 0x2000
|
||||||
|
ctypes.windll.user32.OpenClipboard(None)
|
||||||
|
ctypes.windll.user32.EmptyClipboard()
|
||||||
|
hcd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(url))+1)
|
||||||
|
pch_data = ctypes.windll.kernel32.GlobalLock(hcd)
|
||||||
|
ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pch_data), bytes(url))
|
||||||
|
ctypes.windll.kernel32.GlobalUnlock(hcd)
|
||||||
|
ctypes.windll.user32.SetClipboardData(1, hcd)
|
||||||
|
ctypes.windll.user32.CloseClipboard()
|
||||||
|
else:
|
||||||
|
global clipboard
|
||||||
|
clipboard.setText(url)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@app.route("/heartbeat")
|
@app.route("/heartbeat")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue