0
votes

How to replace in autohotkey ALT + LBUTTON with CTRL + LBUTTON?

What I want is to copy selected text (drag and drop) when is pressed ALT + LBUTTON and dragging (like we do in Windows when using CTRL + LBUTTON and drag selected text)

Here is code which work when we release shortcut but also we have to one more time click on selected text and then drag it.

!LButton:: Lalt::Control

2

2 Answers

2
votes

Here is the solution that I came up with:

!LButton::
    Send {Ctrl Down}{LButton Down}
    dragging := 1
    return

~*LButton::
    if dragging
        Send {Ctrl Up}{LButton Up}
    dragging := 0
    return

I tried using GetKeyState() of the mouse button at first, but I didn't find it to be reliable.

It's also worth noting that !LButton does not behave as the Ctrl modifier does. They must be pressed at the same time, not Alt then LButton.

0
votes

Here is solution:

    ;CoordMode, Mouse, Screen

~!LButton::
    ;MouseGetPos, begin_x, begin_y
    while GetKeyState("LButton")
    {
        ;MouseGetPos, x, y
        Send {ctrl down}
        ;ToolTip, % begin_x ", " begin_y "`n" Abs(begin_x-x) " x " Abs(begin_y-y)
        Sleep, 10
    }
    ;ToolTip
Send {Ctrl up}
return