Retain Shift F Key while mapping F Key

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
mahks
Posts: 2
Joined: 17 Sep 2017, 22:31

Retain Shift F Key while mapping F Key

17 Sep 2017, 22:50

In open office Calc shift F4 is used to toggle absolute cell position.

My ahk script maps F4::^x
this disables the shift F4 function.

Is there a work-around?
User avatar
mahks
Posts: 2
Joined: 17 Sep 2017, 22:31

Re: Retain Shift F Key while mapping F Key

18 Sep 2017, 00:09

Thanks, the tilde sort of worked.

The shift F4 functions and the ^x (cut) also works,
but the F4 default function of open office Calc (open data sources) remains active.

What is that tilde doing? Looks like it allows multiple functions?
Any way to prevent that OOcalc default?
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Retain Shift F Key while mapping F Key

18 Sep 2017, 00:20

Hallo,
see: https://autohotkey.com/docs/Hotkeys.htm
When the hotkey fires, its key's native function will not be blocked (hidden from the system).
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Retain Shift F Key while mapping F Key

18 Sep 2017, 00:29

You're using a remap. Try using a hotkey instead. F4::Send ^x.

When a remap is done, it will tolerate additional modifiers being pressed, and maintain those modifiers in the output. Modifiers are Shift (+), Ctrl (^), Alt (!), and Windows Key (#). In your original code, Shift+F4 isn't disabled, but it produces Shift+Ctrl+x. If you pressed Alt+F4, you'd get Alt+Ctrl+x.

But using a Hotkey, it will only trigger if the modifier conditions match the hotkey definition. In my code, F4 only activates if you are not pressing Shift, Ctrl, Alt, or Win. If you want to be able to use those, you'd either expressly define them as +F4::Send ^+x or you'd use the * modifier which allows any modifier to be pressed and activate that hotkey. However, the * modifier does not make it behave like a Remap -- the Send command is independent of the hotkey's activation conditions. There's no special treatment to Send because you use the * modifier, such that using *F4::Send ^x results in Ctrl+X if you press F4 alone, if you press Shift+F4, if you press Ctrl+Alt+F4, etc.

If you want to achieve a hotkey that acts like a remap (this is more FYI to help you understand what's going on), there is the {Blind} "key" for Send. If you use F4::Send {Blind}^x, what that tells AHK is AHK should not interfere by releasing any of the held down keys. If Shift is in the down position, great, we're pressing Ctrl+X with it to have the net effect in any other program Shift+Ctrl+X. However, because that little code uses F4:: alone, you can nearly guarantee that Shift is not pressed. (I'd imagine it might be possible to have the F4 hotkey be activated, and then the microsecond later you press Shift, but, in reality, that's not happening.) So to make the Hotkey act like remap, you combine it with the * modifier.

Hope that helps!
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Retain Shift F Key while mapping F Key

18 Sep 2017, 04:19

One solution, which Exaskryz already mentioned:

Code: Select all

F4::SendInput, ^x
Another solution, which worked for me on LibreOffice Calc, I don't know whether it would work on OpenOffice Calc (you might have to change 'ahk_class SALFRAME'):

Code: Select all

#IfWinActive, ahk_class SALFRAME
~+F4::
return
#IfWinActive
F4::^x
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Assquatch23, Descolada and 341 guests