Get autohotkey to properly mimic Shift+LButton Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
autohotkey_avatar
Posts: 27
Joined: 04 Aug 2022, 02:51

Get autohotkey to properly mimic Shift+LButton

Post by autohotkey_avatar » 14 Aug 2022, 07:09

If I use shift + left mouse button, and drag my mouse, it will select text dynamically.

But if I try to mimic that in ahk, it breaks:

Code: Select all

LShift & LButton::
   sendinput {LShift Down}{LButton}{LShift Up}
return
What happens is, there will be an initial text selection, but further mouse movements will fail to select more text.

How can I fix this hotkey to achieve what I want?

User avatar
boiler
Posts: 16769
Joined: 21 Dec 2014, 02:44

Re: Get autohotkey to properly mimic Shift+LButton

Post by boiler » 14 Aug 2022, 07:42

Why do you need an AHK script to have it act the way it already acts? What value would the script be adding? I could understand if you were trying to perform the same but using a different key to initiate the drag, but you apparently are trying to have the hotkey do exactly the same as it would without the script.

autohotkey_avatar
Posts: 27
Joined: 04 Aug 2022, 02:51

Re: Get autohotkey to properly mimic Shift+LButton

Post by autohotkey_avatar » 15 Aug 2022, 00:22

boiler wrote:
14 Aug 2022, 07:42
Why do you need an AHK script to have it act the way it already acts? What value would the script be adding? I could understand if you were trying to perform the same but using a different key to initiate the drag, but you apparently are trying to have the hotkey do exactly the same as it would without the script.
Because I'm trying to change the behavior depending on the window the mouse is over.

If it's over notepad or gmail, I want it to behave like normal.

If it's over my special piece of software, I want to customize the behavior.

Code: Select all

; pseudocode
LShift & LButton::
    if(mouse is over my special application)
    {
        ; do the thing i want
    } else {
        ;send LShift & LButton to behave like normal
    }
return

User avatar
boiler
Posts: 16769
Joined: 21 Dec 2014, 02:44

Re: Get autohotkey to properly mimic Shift+LButton  Topic is solved

Post by boiler » 15 Aug 2022, 00:39

Then use an #If directive using the MouseIsOver() function before your hotkey, just like Example #1 from the documentation. Then you wouldn’t have the if/else in your hotkey routine. You would just do the part you want it to do when the mouse is over the window specified in the directive.

Also, don’t use a custom combination hotkey for keys that have standard modifier symbols. Instead of LShift & LButton::, use <+LButton::.

Post Reply

Return to “Ask for Help (v1)”