How to suppress Ctrl + shift hotkey for notepad that enables right to left text formatting?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
iseahound
Posts: 1472
Joined: 13 Aug 2016, 21:04
Contact:

How to suppress Ctrl + shift hotkey for notepad that enables right to left text formatting?

20 May 2024, 17:13

[Moderator's note: Topic moved from Bug Reports.]

1. Suppressing Right Control and Shift disables the RCtrl + Shift + a hotkey.

Code: Select all

>^+a:: msgbox
>^Shift::    Send '{Blind}{vk07}'   
2. Removing the right specifier for control works perfectly.

Code: Select all

>^+a:: msgbox
^Shift::    Send '{Blind}{vk07}'
Last edited by iseahound on 25 May 2024, 11:14, edited 1 time in total.
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Possible bug when suppressing modifier hotkeys

24 May 2024, 20:41

Why would you think that #1 is a bug? Suppressing Shift (Ctrl is not suppressed) means that the logical state of the Shift key does not change. If the logical state of the Shift key is not down, the hotkey >^+a should not fire. This is the correct behaviour. If you don't want the suffix (Shift) to be suppressed, you are supposed to use the tilde (~) modifier.

#2 behaves differently because ^Shift is implemented by the OS, as a registered hotkey. The OS passes the key-down to the keyboard hook, but does not pass it to the active window (so it behaves as though there is one final keyboard hook which suppresses the key-down, after AutoHotkey has been notified of it). The key-up is passed to both the keyboard hook and the active window. AutoHotkey's keyboard hook only pays attention to "hook" method hotkeys, so does not treat Shift as though it will be suppressed. The hook also wouldn't know if some other process or script registered ^Shift as a hotkey.

Your topic title says "suppressing modifier keys", but I think you're only referring to sending vk07, which is not suppressing the modifier key at all, but suppressing whatever action that would take place if you press and release Ctrl+Shift without pressing any other combinations (probably a language-switch). Maybe you didn't realize that one of the hotkeys does actually suppress the modifier key.
iseahound
Posts: 1472
Joined: 13 Aug 2016, 21:04
Contact:

Re: Possible bug when suppressing modifier hotkeys

25 May 2024, 06:30

Is it possible to block the action tied to the hotkey Ctrl + Shift without interacting with the other hotkeys then?


Looks like any "suppression" fails with send inside the hotkey.

Code: Select all

#Requires AutoHotkey v2.0

~>^RShift::    ; Notepad Right to Left reading order
~>+RCtrl::     Send '{Blind}{vk07}'

>^+Left:: Send 'a' ; Still enables right to left reading order in notepad.
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: How to suppress Ctrl + shift hotkey for notepad that enables right to left text formatting?

26 May 2024, 03:42

Send 'a' implies that Ctrl and Shift will be released and pressed back down again. AutoHotkey will not automatically mask them when this happens, because it is not designed to. (Perhaps it should try to suppress the Ctrl+Shift language-switching hotkey, but I think Notepad's hotkeys are outside the scope of what AutoHotkey should be expected to compensate for.)

So if the modifiers are not masked automatically, you must either mask them yourself whenever it is needed (i.e. after each time Send restores Ctrl and Shift) or find some other way to disable the shortcut.

There is probably a way with #InputLevel/SendLevel and/or InputHook to detect when Ctrl and Shift are sent in combination, and send the mask key at that time. Another way would be to suppress the user's press and release of RShift/RCtrl, but send them yourself, along with the mask key. (But in that case, consecutive calls to Send might still trigger the hotkey.)

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: ntepa and 25 guests