I want ctrl + { to work as the home key.
This doesn't work:
^{::Send {Home}
I guess the { needs to be escaped?
This also doesn't work: (it generates an error on loading the script)
^{{}::Send {Home}
What is the correct way of doing this?
You can use the steps listed here to find the scan code and virtual key code of the { and then use either of those (SCnnn or VKnn) in the hotkey definition.
Even though that works I was curious why the ^{ doesn't work for your layout, so I tried using it and seeing if AHK's key history showed {, which it does. I took a look at AHK's source code to see what's happening, and I think it comes down to the return value of VkKeyScanEx called with { and your layout, which is 0x0634, i.e., AltGr+4. I hadn't noticed that AltGr+4, AltGr+5, and AltGr+9 all produce { in your layout before this, so I tried the ^{ hotkey again and sure enough it fires with AltGr+4. So it seems it's just a limitation of VkKeyScanEx: even if multiple combinations map to some character only one of them can be returned. In your .klc file, wherever LEFT CURLY BRACKET first appears will be the combination that VkKeyScanEx returns. I don't know if you use the AltGr combinations for {, but if you remove them from your layout the ^{ hotkey should work for just Ctrl+{.
Related
I've seen a ton of questions about TinyMCE shortcuts, but nothing quite like this.
I have a situation in which I am iterating over an object of shortcuts I want to add to TinyMCE.
The shortcuts add functionality for the greater app around the editor.
For the most part, it works fine.
However, it appears that I cannot add certain combinations. For example, alt+l and alt+left.
Take this code:
_.each(oHotKeyCollection, function (oHotKey, sHotKey) {
this.editor.addShortcut(sHotKey, oHotKey.note, function (e) {
if (!e) {
e = event;
}
// sHotKey is the pattern (ie. alt+l)
alert(sHotKey)
oHotKey.execute(e);
}.bind(this));
}
}.bind(this));
When alt+l is added, and then alt+left is added, hitting alt+l on the keyboard will bring up an alert with alt+left.
Removing the alt+left shortcut allows alt+l to function as expected.
The same behaviour seems to be true of alt+r and alt+right as well as alt+u and alt+up.
How I can get both shortcuts working?
The problem is that only certain keywords can be used in a shortcut, such as the modifier names (ctrl, alt, etc...). Anything else is treated as a single key so left in this case isn't valid and is treated as just being l (see Shortcuts.ts). That's why alt+l is being overridden with your alt+left behavior.
So to fix that, you'll need to use the keycode for left instead of a keyword. In this case that would be alt+37. Here's a fiddle showing that working by printing to the console: https://fiddle.tiny.cloud/EEhaab.
Since you also mentioned you're trying to register other arrow keys, here's the key combinations you'd need to use:
Left: alt+37
Right: alt+39
Up: alt+38
Down: alt+40
I'm developing some C++ code with VSCode+VIM extension. From time to time I need to do this while reading code: say I'm inside a long function and I want to know who called it. The first step to do is to move cursor directly under function's name so that I can invoke some keystrokes to show references.
What I'm current using is to press "[" key twice which will bring me to the opening bracket of the function. Since I have to follow some coding standard, the typical scenario is like this:
ReturnType ClassName::FunctionName(
ParamType1 param1,
ParamType2 param2,
ParamType3 param3)
{ // <-- Cursor here
......
}
Then I need to press "k" several times to move cursor under "ReturnType", depending on how many parameters are there. Next, I still have to press "w" 3 times to eventually move cursor from "ReturnType", to "FunctionName".
As you can see, this is a little painful here. I've tried easy motion approach with VSCode VIM extension, this makes my life a little easier, but I'm looking for a even better one.
Any VIM trick or VSCode extension can do this decently?
Any help will be appreciated, thanks!
To avoid having to press k a variable number of times it's possible to make use of the fact that the ) is right on the line above, and use % to go to the matching (. The complete key sequence is [[b%b.
However the first b will go to the ( if there's nothing between the parentheses. [[ge%b can be used instead.
If there's something between ) and { (such as a const qualifier) [[?)<cr>%b would work (this solution is complex and perhaps only useful in a key binding?)
[[?(<cr>b works too as long as there's no parameter that contains an open parentheses (such as in FunctionName(int (*function_pointer)(int, int)) { ... })
I would like to remap the 'j' key so that it presses n when ergo is true, or y when it is false with AutoHotKey. When I remap normally using "j::n" for example, shift+j outputs a capital N, and so do other modifiers with the 'j' key. However, my code below only works when the letters are pressed without modifiers. Is there a way to get around this, and conditionally remap keys with AutoHotKey?
j::
if (ergo) ;inverted use of the ergo variable to make the code more efficient
Send {n}
else
Send {y}
return
You only want to wrap characters which have a special meaning in a send command in { }. Basically escaping, if you're familiar with that what is.
So you don't want to wrap n or y in { }. It can even result in undesired behavior.
There are quite a few approaches for this. Can't say which is best, since don't know what your full script is like.
I'll present two options that I'd guess to be most likely best approaches for you.
Firstly, the send command way like you tried. Just doing it right:
*j::
if (ergo)
SendInput, {Blind}n
else
SendInput, {Blind}y
return
So, usage of the *(docs) modifier so the hotkey works even if extra modifiers are being held down.
And then usage of the blind send mode so which ever modifier keys you may be holding when triggering the hotkey will not be released.
Also switched over to SendInput due to it being the recommended faster and more reliable send mode.
Second way would be creating a context sensitive hotkey with #If(docs).
#If, ergo
j::n
#If
j::y
This is a convenient and easy approach. But could possibly result in other problems.
Why? Well #If comes with some downsides which you can read more about here, but long story short:
You likely wont have any trouble unless you have a more complicated script.
When I remap normally using "j::n" for example, shift+j outputs a capital N, and so do other modifiers with the 'j' key. However, my code below only works when the letters are pressed without modifiers.
Looks like you are looking for the Wildcard * modifier.
From the docs:
Wildcard: Fire the hotkey even if extra modifiers are being held down. This is often used in conjunction with remapping keys or buttons.
So after this change, your code would look something like:
*j::
if (ergo) ;inverted use of the ergo variable to make the code more efficient
Send {n}
else
Send {y}
return
I'm trying to use Auto Hot Key to replace $ with %. I also am replacing & with $.
My problem is that when I press the & key (now remapped to $), it thinks I'm actually pressing $, so it triggers the code and types %.
This is the code:
~::#
#::?
%::^
^::~
$::Sendraw `%
&::$
?::+
/::_
+::&
=::/
_::=
My keyboard layout doesn't have these keys as actual keys, so I can't really test this for you, but I can still tell you what will likely fix the problem, and then an other version which will definitely fix the problem.
So the thing that will likely fix the problem is using the $ modifier (docs). You should only need it for the $::Sendraw `% hotkey, because the other hotkeys use the remapping syntax and will automatically do what adding the $ does.
So your script would look like this:
~::#
#::?
%::^
^::~
$$::SendInput, `%
&::$
?::+
/::_
+::&
=::/
_::=
(and I also switched to using SendInput because SendRaw really made no sense there)
That should work if all the hotkeys are as actual keys on your keyboard layout (as opposed to being accessible with modifier key combos (e.g. CTRL + ALT + 2), like they are on my keyboard layout).
Why it wouldn't work when having to mess with modifiers keys is a bit more complicated. I can explain it in detail if you're actually interested, but for now I'll just say it's because of the blind send mode the remapping syntax uses.
So, not using the remapping syntax like this should ensure it'll work on any keyboard layout no matter what:
*~::SendInput, #
*#::SendInput, ?
*%::SendInput, {^}
*^::SendInput, ~
*$::SendInput, `%
*&::SendInput, $
*?::SendInput, {+}
*/::SendInput, _
*+::SendInput, &
*=::SendInput, /
*_::SendInput, =
Here we're using the * (docs) modifier to deal with having to hold modifier keys to access hotkeys. And we're not using $ modifier, because using * already does what $ does. So having them both would be redundant.
+4::SendInput, `%
This should work fine.
I have an editor which is linked to a database field.
When the user pushes certain keys the program should behave differently,
for the rest of keys it should maintain the default behaviour. I am using this part of code:
ON ANY-KEY OF editor_1 IN FRAME F-Main
DO:
APPLY LAST-EVENT:LABEL TO SELF.
RETURN NO-APPLY.
END.
The problem is that when APPLY LAST-EVENT:LABEL is executed the editor does not behave as default.
Some examples of the behaviour by default, i.e. when any-key is not triggered:
CTRL+C is used for copying selected text
CTRL+V is used for pasting the copyed text
After triggering any-key in the editor, the program works like this:
CTRL+C aplication ABORTS
CTRL+V does not work
CURSORS DOWN/RIGHT/LEFT/UP do not work
BACKSPACE does not work
Is there anyway of triggering any-key without overwritting the default behaviour?
Note: Progress 4GL is v11.3 and is executed from windows.
You should map the key labels to the key FUNCTION that you want to apply.
Something like:
ON ANY-KEY OF editor_1 IN FRAME F-Main
DO:
if last-event:label = "backspace" then
apply delete-char to self.
else
apply lastkey to self.
/* use a CASE statement to extend this... */
RETURN NO-APPLY.
END.
I talked to progress and there is no solution for this issue. This issue with ANY-KEY is related to editors.
You could map some key labels to specific key FUNCTION, but there are certain events where it is not possible (for example, cursor movements).
At the end I had to trigger for special keys, but in this particular case it was preferable something like ANY-KEY.
Instead of triggering an event on any key, why not just do it for those special keys?
For example, the control-C behavior would be in this trigger:
ON CTRL-C of editor_1 IN FRAME F-Main