[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simulating mouse-clicks
From: |
Zhiwei Chen |
Subject: |
Re: Simulating mouse-clicks |
Date: |
Mon, 20 Sep 2021 02:30:28 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Ag Ibragimov <agzam.ibragimov@gmail.com> writes:
> Can someone share an example, Emacs Lisp snippet where mouse-click gets
> simulated, e.g., programmatically clicking mouse-1 in current window. I
> can't figure this out. Thanks!
#+begin_src elisp
(defun left-is-clicked ()
(interactive)
(message "mouse left button is clicked"))
(global-set-key (kbd "<mouse-1>") #'left-is-clicked)
(defun simulate-left-click ()
(interactive)
(push '(t . mouse-1) unread-command-events))
(global-set-key (kbd "C-c d") #'simulate-left-click)
#+end_src
Press C-c d to see the result, bro.
--
Zhiwei Chen