diff --git a/onionshare_gui/static/onionshare.js b/onionshare_gui/static/onionshare.js
index c470268d..6c7b7fa0 100644
--- a/onionshare_gui/static/onionshare.js
+++ b/onionshare_gui/static/onionshare.js
@@ -3,7 +3,7 @@ $(function(){
function update($msg) {
var $line = $('
').append($msg);
- $('#log').append($line);
+ $('#log').prepend($line);
}
function copy_to_clipboard() {
diff --git a/onionshare_gui/webapp.py b/onionshare_gui/webapp.py
index d2c951cf..80f2c3f8 100644
--- a/onionshare_gui/webapp.py
+++ b/onionshare_gui/webapp.py
@@ -65,8 +65,22 @@ def start_onionshare():
@app.route("/copy_url")
def copy_url():
- global clipboard
- clipboard.setText(url)
+ if platform.system() == 'Windows':
+ # 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 ''
@app.route("/heartbeat")