tumashu / exwm-x

A derivative WM based on EXWM (emacs x window manager)
82 stars 8 forks source link

exwmx-sendstring not working for google-chrome-stable #8

Closed QiangF closed 6 years ago

QiangF commented 6 years ago

The paste key is "C-v", paste works if the key is typed with keyboard. Also the command works for other applications, including firefox.

tumashu commented 6 years ago

try Ctrl+Shift+V

QiangF commented 6 years ago

我试了 (setq exwmx-sendstring-default-paste-key "C-S-v") 也不行。

tumashu commented 6 years ago

首先看看 C-S-V 这个快捷键能不能再 chrome 中使用, 如果可以,就运行 exwmx-appconfig,会弹出一个buffer 让你更改当先 app 的 appconfig, 调整里面的 appconfig后保存就可以了, 如果还不行,那就是 exwm 的按键模拟功能不适合chrome

QiangF commented 6 years ago

都不行,只能用chrome插件了,大师有空帮找下原因吧。

QiangF commented 6 years ago

I find a solution:

(defun exwmx-sendstring--send (string)
"Send `string' to clipboard and then send paste key to
application to trigger paste operation, `string' will be
inserted into the application."
(if (derived-mode-p 'exwm-mode)
    (let ((paste-key
            (or (plist-get (exwmx-appconfig--search
                            `((:class ,exwm-class-name)
                            (:instance ,exwm-instance-name)))
                            :paste-key)
                exwmx-sendstring-default-paste-key)))
        (kill-new string)
        (message "paste key is %s" paste-key)
        (dolist (key paste-key)
        (start-process-shell-command "xdo paste" nil (concat "xdotool key --delay 40 " key)))
        (setq kill-ring (cdr kill-ring)))
    (insert string)))
ghost commented 5 years ago

我的也是一样不行。除了chrome,在firefox正常。 在chrome我要手动 C-c C-q C-v 粘贴一下。 试了上面的方法也还是不行。 用的 exwm-edit有时候可以有时候不行。

QiangF commented 5 years ago

试试这个,用了sleep-for

(defun exwmx-send-paste-key ()
(interactive)
(let* ((paste-key (or (plist-get (exwmx-appconfig--search
                            `((:class ,exwm-class-name)
                            (:instance ,exwm-instance-name)))
                                :paste-key)
                        exwmx-sendstring-default-paste-key)))
        (sleep-for 0.2)
        (exwm-input--fake-key (aref (kbd paste-key) 0))))
tumashu commented 5 years ago

@QiangF 延迟0.2秒就可以么?

QiangF commented 5 years ago

嗯 反正我现在没有问题

ghost commented 5 years ago

可以了。以前在windows上折腾autohotkey,很多都是顺序/延时的问题啊。

ghost commented 5 years ago

看了下 exwm-edit的源码,它也加了延时,只不过只有 0.05s,怪不得我用的时候有时候有效,有时候没效。 (run-at-time "0.05 sec" nil (lambda () (exwm-input--fake-key ?\C-v))) exwm-edit会把文本框已有的内容复制到buffer供编辑。先用exwm-edit了。