Alt HMC in Autohotkey - autohotkey

I am trying to remap a function key like F4 to do an ALT then press H + M + C.
Tried reading the docs but was not successful in getting my answer.
I actually thought this may work but it's not.
F4::!hmc

That was probably working, but AutoHotkey runs too fast for most applications to pick up on the macros. It looks like you want to manipulate Word or some sort of ribbon menu. Try this:
SetKeyDelay, 50 ; Increase this to increase the delay
F4::!mhc
You could also try switch our your ! for {Alt} and see if you get any improvements there. Let me know if this works for you.

Related

Remap "RCtrl + Arrow" to "End" but keep other modifiers

I am trying to replace the RControl + Right Arrow to End, but I want to keep other modifiers functionality (like combining it with Shift or even Control for Shift+End or Ctrl+End).
I tried:
*>^Right::End - doesn't ignore the RControl, so I am unable to press End, only Control+End.
*>^Right::Send {End} - doesn't send my other modifiers, so even if I do Shift + RControl + Right it will register only End.
As far as I could find information, the second one should work fine because of the * on it (it should let other modifiers go through), but it's not working.
Any tips on this? This is really hurting my productivity as my new keyboard have the Fn key on the right side and I always use Fn+Keys for Home/End and I can't seem to find a good alternative on my current layout.
Thanks.
You can use Send with blind mode to allow all modifiers except RControl to pass through:
*>^Right::Send {Blind}{RCtrl Up}{End}
This is like what your first try (*>^Right::End) does internally; it just doesn't send {RCtrl Up}.

Use 'J' key to goto next match in Vrapper

Question
Is there a way to get j to move to the next result in the Eclipse auto-complete popup when using Vrapper?
Rationale
When I use Eclipse auto completion Ctrl+Space, I would like to use the j and k keys to move to the next and previous match. I get so used to moving this way in Vrapper that it is a bit hard to switch tactics in the specific Eclipse situations that Vrapper does not control. The auto-complete popup is the most common of these situations for me.
Possibilities
I see several possibilities for solving this:
Write a feature request for Vrapper to solve this (if it isn't solved already)
Create a key combination in Eclipse if the command for this is exposed
Create a key combination outside of Eclipse that sends a ↓
Live with using the ↓ key like everyone else does
Perhaps there is a .vimrc trick such as mapping j to ↓and Eclipse will capture that ↓
My workaround for this until I find a better one is to use the following AutoHotkey script:
#j:: ; The # stands for the left win key
SendInput {Down}
return
#k::
SendInput {Up}
return
I'm not completely happy using the Win+j combination, but it seems to work fairly well for now.
I asked this same question on github and got the following response which answers the question. I'm re-posting it here.
We have an option :set contentassistmode which will enable Ctrl-n/Ctrl-p to go to next/previous match in the Ctrl-Space pop-up. You can then use :camap to remap and to j and k or any other key you want. I'm sorry but we don't have a solution for the quick-fix pop-up.
See http://vrapper.sourceforge.net/documentation/?topic=configuration#vrapper
Link: https://github.com/vrapper/vrapper/issues/648

Emulating Ctrl + Spacebar + AlphabeticalKey with Autohotkey

My problem :
^space & c::
send {F2}
send {Escape}
but it didn't work, how do I emulate Ctrl+Space + AlphabeticaklKey ?
As my previous speakers said, it can't be done easily. Here's my suggestion, it seems to work fine:
^space::
Loop {
if(GetKeyState("c")) {
break
}
if(!GetKeyState("CTRL") || !GetKeyState("SPACE")) {
return
}
Sleep, 50
}
msgbox, You have pressed CTRL+SPACE+C
return
The code is pretty self-explanatory. When CTRL + SPACE is pressed, it waits until either one of both is released or C is pressed. The latter triggers the actual functionality, otherwise it will return.
I actually don't like it very much, because theoretically it may fail in some cases (e.g. when CTRL + SPACE + C is pressed and released before the execution reaches the check for the state of C; although that seems very unlikely).
Update
There's also a way using #If. I recommend using that since it's more sophisticated and reliable. This is due to the fact that it doesn't need any loops:
#If GetKeyState("SPACE")
^c::Msgbox, You have pressed CTRL+SPACE+C
#If GetKeyState("c")
^space::Msgbox, You have pressed CTRL+SPACE+C
As far as I know, you can only combine two non-hotkey keys with the syntax:
space & c:: msgbox space and c
You can read it here
You can define a custom combination of two keys (except joystick
buttons) by using & between them. In the below example, you would hold
down Numpad0 then press the second key to trigger the hotkey:
Numpad0 & Numpad1::MsgBox You pressed Numpad1 while holding down
Numpad0. Numpad0 & Numpad2::Run Notepad
Trying to use control as well like in: space & c & control or space & ^c or any other combination will result in compile error.
My recommendation is that you don't combine that three keys together. Look for a pure hotkey combination or use another more or less useless key.
#!c:: windows + alt + c
AppsKey & c::
Remember that if you use a normal key as modificator, you have to remap it to itself to keep the original functionality, for example with the menu key (appskey):
AppsKey:: Send {Appskey}
AppsKey & c:: ;do what you want
There are actually a couple ways to get help. First of all the authors of this language have moved to a new domain ahkscript.org. It is always welcome to ask questions like these in our forum. I just happened to be digging through this site today and saw this by accident.
When you have more than one line of code after a hotkey you need to have a return follow it:
^space & c::
send {F2}
send {Escape}
return
Hope that helps

autohotkey does not exist in current keyboard layout - solution examples

I have written a python script for my co-workers, and then created an autohotkey script to run it every time someone presses Ctrl+LShift+Y. Looks something like this:
^+y::Run helper.py
The python script is fine, but the ahk script doesn't work on all the computers. Sometimes it works fine, and sometimes you get this error:
^+y does not exist in current keyboard layout
Now, searching the web this seems to be a problem with multi-language keyboards (we're using both Hebrew and English), because different languages means a different layouts (I guess?). I also found someone explaining that to solve this you need to use scan codes instead of the usual ^ and + and so on (I'd link to it but I cannot seem to find it now).
This all vaguely makes sense to me on a theoretical level, but when I want to realize it with actual code, I don't really know what to do. To me it seems as if this topic is hardly discussed (with the few exceptions being lacking in examples or hard to understand), so I'd love an answer that would include the following:
some simple way of determining the scan code for a key. This should preferably be a pythonic solution (and just out of curiosity, I'd love to know how to do this with linux as well). This is probably the easier part (but I think is an inherent part of a complete answer).
This is the important part: examples of how you implement that scan code in an autohotkey script, including edge-cases (if there are any).
Question 1
As you want to use the key with autohotkey, it makes sense to use autohotkey detect the key in the first place. Obviously this method works only on windows where autohotkey is running.
Write a Autohotkey script with this line and run it.
#InstallKeybdHook
Press the key you want to examine.
Open the script menu by right clicking the icon of the script in the right lower corner of your screen.
Select OPEN, then from the Menu "View / Key history and script info"
There is a line for each keypress.
First column is the VK (Virtual key) code, next is the scancode.
For example for CAPSLOCK the VK is 14 and the Scancode 03a
Question 2:
#InstallKeybdHook
VK14::
msgbox, you pressed capslock!
return
OR
#InstallKeybdHook
SC03a::
msgbox, you pressed capslock!
return
both work.
Note that you can combine two keys into a hotkey by combining them with & (but not 3)
#InstallKeybdHook
RShift & SC03a::
msgbox, you pressed Rshift capslock!
return
You can modify a Scancode with + and ^
#InstallKeybdHook
^+SC02C::
msgbox, you pressed Ctrl Shift and Y(maybe)!
return
Further info about this is on the page "List of Keys, Mouse Buttons, and Joystick Controls" of the autohotkey help file that comes with the default installation.

Autohotkey: Commands with Alt Key Working Properly only if not Restricted to a Specific Application

I'm trying to add custom keyboard commands to an application using Autohotkey.
In many of these hotkeys I would like to use the alt key in combination with some other key of my choice (any of the standard letters).
All works fine as long as I don't restrict their usage in such a manner that they work in the target application only (via the #IfWinActive directive ). If I do so, the hotkeys themselves still work, however their behavior is very strange.
I found that they get activated either if
a) I hold down the alt key and then press the second key (in my case the 'b' key) twice
or
b) I use this hotkey two times consecutively with a very short delay between the two triggerings
- The above two cases might actually be 1 case. I'm not sure...
I have no problems when doing the same with Shift or CTRL.
The 'b' key is not what's causing the problem - no alt + 'letter' combination works.
I have tried all SendModes, but so far with no effect.
Code sample:
#IfWinActive, MyAppTitle ahk_class MyAppClass
!b::
click 367, 86
return
Alt+letter commands in AutoHotkey such as !b work without issue. It's possible the version at the time of this post contained certain bugs or was out of date from the current version.
For your code, it could be done like so:
!b::
WinGetTitle, Title, A
if (RegExMatch(Title, "MyAppTitle"))
{
MouseClick, left, 367, 86
}
return