Hotkey to remap keys does not trigger hotstring

断了今生、忘了曾经 提交于 2019-12-22 00:06:50

问题


I have a hotkey and hotstring that don't seem to work together:

9::(

:?ob0:(::){left 1}

To give some context, in one part of the code I remapped all the symbols to the number below them and vice versa so 9 prints the parenthesis (. Later on I put a hotstring that would type a closed parenthesis after an open one and then places the cursor in between.

Seems simple enough because they both work individually but together when I press the key for 9 and press the Spacebar I only get the open parenthesis ( as if the hotstring was ignored.

Am I missing something obvious?


回答1:


Try using a combination of Send and InputLevel.

#InputLevel 1
9::SendEvent (
#InputLevel 0

;; Add closing parenthesis
:?ob0:(::){left 1}

Explanation

  • #InputLevel

    • By default, hook hotkeys and hotstrings ignore keyboard and mouse events generated by any AutoHotkey script. This behavior can be overridden using SendLevel or #InputLevel
    • By setting the 9 hotkey to a higher InputLevel, it is able to the activate other hotstrings.
  • SendEvent

    • Bizarrely, remapping a numkey to its Shift+# equivalent produced no input when #InputLevel 1 was active.
      • i.e. Couldn't use 1::!, 2::@, 3::#, ..., 8::*, 9::(, etc.
      • A Send command was used to workaround this remapping limitation
    • By default, Send and SendEvent are synonymous with each other.

Notes

  • SendPlay is not affected by InputLevel.
  • Remarks for Remapping Keys may explain why 9::( wouldn't trigger other hotkeys.
    • "Although a remapped key can trigger normal hotkeys, by default it cannot trigger mouse hotkeys or hook hotkeys."

Related

#InputLevel, Send, Remapping (Remarks)



来源:https://stackoverflow.com/questions/46364992/hotkey-to-remap-keys-does-not-trigger-hotstring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!