Prevent shift key in hotkey affecting shift commands in script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Lem2001
Posts: 127
Joined: 27 Jun 2017, 17:59

Prevent shift key in hotkey affecting shift commands in script

Post by Lem2001 » 21 Dec 2022, 04:23

I am trying to use a hotkey (^+Z) to run some code that involves selecting text.

Code: Select all

; Test Example
SendInput, {Shift down}
SendInput, {Right 5}
SendInput, {Shift up}
However, this doesn't work because the shift key in the hotkey interferes with code that selects the text.

I tried using $^+Z (which is supposed to stop a hotkey from sending itself) but it didn't make any difference.

I then tried putting {Blind} in front of the shift commands ({Blind} {Shift up} etc) but that didn't work either.

I also tried using Hotkey, Shift, On immediately after the hotkey. to temporarily disable the Shift key altogether, but text selection still didn't work,

I have probably not used these options correctly, so can anyone please tell me what I'm doing wrong?

Alternatively, is there another way to select a range of text other than by manually using the Shift and Arrow keys?

I'm already using ControlGet, OutVar, Selected to obtain text selections, but I don't know if there is an equivalent feature that can apply or set text selections. That would obviously solve the issue because shift would no longer need to be pressed as part of the text highlighting code.

ntepa
Posts: 439
Joined: 19 Oct 2022, 20:52

Re: Prevent shift key in hotkey affecting shift commands in script  Topic is solved

Post by ntepa » 21 Dec 2022, 05:06

This works for me.

Code: Select all

^+z::
    Send, +{Right 5}
Return

Lem2001
Posts: 127
Joined: 27 Jun 2017, 17:59

Re: Prevent shift key in hotkey affecting shift commands in script

Post by Lem2001 » 21 Dec 2022, 11:45

Wow, this is so simple and effective! I can't believe that I overlooked this method.

Thank you @ntepa

Post Reply

Return to “Ask for Help (v1)”