Copy to Clipboard with Lbutton and Rbutton

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
formulaone
Posts: 3
Joined: 01 Oct 2022, 14:12

Copy to Clipboard with Lbutton and Rbutton

Post by formulaone » 01 Oct 2022, 14:21

I have this hotkey that copies text to the clipboard when the left and right mouse buttons are pressed.

Code: Select all

LButton & RButton::
	Clipboard=
	send, ^c
	ClipWait, 1, 1
return
It works in most windows except this one particular dialog window. If I change the hotkey to a single key or to the right button only then it works. What can I do to make it work in that one window with the left and right mouse buttons?


[Mod edit: Changed AutoIt codebox to default AutoHotkey type.]

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Copy to Clipboard with Lbutton and Rbutton

Post by mikeyww » 01 Oct 2022, 14:49

Welcome to this AutoHotkey forum!

1. Add a display line that indicates to you whether your hotkey is being triggered.
2. If the hotkey is triggered, display the value of the clipboard after the copying.
3. Do a manual test of Ctrl+C to see what is captured to the clipboard.
4. Display the ErrorLevel from the ClipWait.

formulaone
Posts: 3
Joined: 01 Oct 2022, 14:12

Re: Copy to Clipboard with Lbutton and Rbutton

Post by formulaone » 02 Oct 2022, 03:19

The value of the clipboard is blank and the ErrorLevel is 1.
CTRL + C copies the selected text as expected, but makes an error sound.
The ErrorLevel is 0 and works if the hotkey is the Rbutton.

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Copy to Clipboard with Lbutton and Rbutton

Post by mikeyww » 02 Oct 2022, 07:07

Thank you for the details. Since other hotkeys work, other windows work, and a manual copy creates an error sound, it sounds like this particular window, whatever it is, is creating difficulty. Perhaps the window creates its own hotkey for your LButton or for the key combination. In that case, you may have a software or hook conflict. It sounds like something else may be happening. I do not have an answer, especially because you provide no way to test this. Others may have a solution.

formulaone
Posts: 3
Joined: 01 Oct 2022, 14:12

Re: Copy to Clipboard with Lbutton and Rbutton

Post by formulaone » 03 Oct 2022, 14:48

Thank you for the reply. It was helpful because it made me think to try adding {LButton Up} before ^c, which worked!

Code: Select all

LButton & RButton::
	send, {LButton Up}
	Clipboard=
	send, ^c
	ClipWait, 1, 1
return
[Mod edit: [code][/code] tags added.]

Will this cause problems because I'm sending {LButton Up} without an {LButton Down}? Is there a safer alternative?

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Copy to Clipboard with Lbutton and Rbutton

Post by mikeyww » 03 Oct 2022, 14:56

No problems, but your testing will answer the question more definitively.

Post Reply

Return to “Ask for Help (v1)”