dual icon indicating copy to clipboard operation
dual copied to clipboard

dual.modifier() successfully remaps Win->Alt, but not Ctrl->Alt

Open dimhatz opened this issue 7 years ago • 5 comments

Bug report

Hi, first of all thank you very much for your awesome code!

I'm trying to achieve the following:

  • Alt keys to produce Ctrl when held down and parens "(" and ")" when tapped Flawlessly done with:
*LAlt::
*LAlt UP::dual.combine("LCtrl", "(")
*RAlt::
*RAlt UP::dual.combine("RCtrl", ")")
  • Shift keys to remain Shift when held down and produce curly braces "{" and "}" when tapped Flawlessly done with:
*LShift::
*LShift UP::dual.combine(A_ThisHotkey, "{")
*RShift::
*RShift UP::dual.combine(A_ThisHotkey, "}")
  • Ctrl keys to produce Alt without breaking multi-modifier combinations (ex. Ctrl+Alt+T) This is where my issue is. The closest I've got is successfully make Win keys become Alt (but still not good enough - the point is to get Ctrl to produce Alt):
; works as expected alone and in combination with the above
*LWin::dual.modifier("LAlt")
*RWin::dual.modifier("RAlt")

; fails both alone and in combination with the above
*LCtrl::dual.modifier("LAlt")
*RCtrl::dual.modifier("RAlt")

I have opened Notepad and Keypose to monitor what is being sent to it. The Win mappings work correctly, the Ctrl ones do not. Pressing Win+T correctly produces Alt+T. Pressing Ctrl+T incorrectly produces Alt+Ctrl+T. Expected to produce Alt+T.

Here is the minimal reproducible code:

SendMode Input
#NoEnv
#SingleInstance force

#Include dual.ahk

dual := new Dual 

#Include defaults.ahk

#If true ; Override defaults.ahk. There will be "duplicate hotkey" errors otherwise - orig. author

*ScrollLock::dual.reset()

*LWin::dual.modifier("LAlt")
*RWin::dual.modifier("RAlt")

*LCtrl::dual.modifier("LAlt")
*RCtrl::dual.modifier("RAlt")

#If

Other things I have tried that didn't work:

  • Most obvious to try direct remapping:
LCtrl::LAlt
RCtrl::RAlt
; OR
*LCtrl::LAlt
*RCtrl::RAlt

Half-works in combination with first sets of mappings, requiring the multi-modifier sequence (like Alt+Ctrl+T) to begin with physical-Alt (produces Ctrl), then physical Ctrl (produces Alt), then letter T. Else the sequence will only produce Ctrl+T.

  • Use comboKey to remap Ctrl.
*LCtrl::dual.comboKey("LAlt")
*RCtrl::dual.comboKey("RAlt")

Ctrl will now produce Alt when pressed on its own, but in combination will produce Ctrl (ex. pressing physical Ctrl+F4 expecting to produce Alt+F4, but producing Ctrl+F4). This is probably me not understanding correctly the comboKey function.

Any help will be greatly appreciated, as this is my only way to make Windows tolerable..

P.S. My system is Win7 x64, Autohotkey 1.1.26, and latest Dual. Oh, and the gist with commented out the above pieces of code for convenience: https://gist.github.com/dimxdim/1a96506e0997092565c0f1eb51ad7b50

Thank you very much in advance for any help/advice!

dimhatz avatar Jun 13 '17 18:06 dimhatz

Glad you like it! Unfortunately, I have no idea why it’s not working for you.

As mentioned in the readme, I don’t use Autohotkey anymore (and haven’t done so for 3 years), so I think you might be better off asking somewhere else :)

lydell avatar Jun 13 '17 18:06 lydell

Thx for such a prompt reply! I guess for now I will be using a (hackish) workaround of doing all the remapping on lower level (SharpKeys - registry modification) and only the "unpresses" will be handled by Dual. I will try to dig further to get to the bottom of the issue. I will post any results here. (EDIT: clarity)

dimhatz avatar Jun 13 '17 20:06 dimhatz

Hi lydell i also use linux is there an equivalent script like this that you use for linux to achieve same dual role result

mokanfar avatar May 27 '18 23:05 mokanfar

None that I'm aware of. But I don't use dual-role keys anymore. If you really want them, I think the best way to do it is through keyboard firmware, unfortunately. Examples:

  • https://qmk.fm/
  • https://github.com/keyboardio/Kaleidoscope/

lydell avatar May 28 '18 05:05 lydell

@mokanfar Last year I spent some time customizing my keyboard experience and eventually wrote a Python library (based on evdev) which enables anything I wanted and is easy to maintain and extend. Check out https://gitlab.com/notEvil/keyboard. Its far from simple to use, but with a little trial and error and a look at main(), SubstituteKeyCodes and ModifierAsKey the result should be close to dual. Hope it works for you as well as it does for me!

notEvil avatar Aug 18 '20 12:08 notEvil