I have a very similar issue that I have been struggling with: I am trying to create a hotkey that will send this:
{control}or more specifically {left control down} {left control up}
(It is the backwards apostrophe symbol that usually sits on the same key as the ~ on most keyboards.)
Sending ^` doesn't seem to work.
any suggestions?
Related
I am trying to build a very simple AutoHotkey script but it doesnt seem to be working. I've bought a keyboard with no Win key and no programable hardware layer so I am planning on using AHK to remap the Alt Gr key to the Windows key.
Can anypoint give me pointers to where I am going wrong.
<^>!l::
MsgBox Win L pressed.
return
<^>!r::
Send {# down}
Send {r down}
Send {# up}
Send {# up}
return
<^>!e::
SendInput #&e
return
Using your middle example, it'd be like so:
<^>!r::
SendInput, {LWin Down}r{LWin Up}
Return
You can use RWin or LWin per your preference since it really shouldn't matter at the software level.
I just started using Autohotkey (I am a noob with it) for remapping some key combinations like CTRL+TAB (which is good if you are using your left hand) to be accessible while using your right hand.
My initial script is the following:
RControl & RShift::
{
send {LControl down}{tab}{LControl up}
return
}
It works fine, but while switching tabs in Visual Studio, for example, I cannot hold the CTRL key to keep switching tabs, I can only switch between 2 tabs.
Does anyone know if it is possible to achieve this kind of functionality with Autohotkey?
Thanks in advance.
You don't need the { } around the hotkey body. Hotkeys simply start with :: and end with return. Braces are only needed in functions afaik.
send {LControl down}{tab}{LControl up} could be expressed easier by send ^{tab} which is Ctrl+Tab. The tab-switch in VS also works with right RCtrl.
In either way, this does not work because of the send {ctrl up}. Ctrl needs to stay pressed down in order for the "Active files" window to stay open. Try:
RControl & RShift::send {RCtrl down}{tab}
I am capturing a user hotkey choice using GuiControl, hotkey then save to an ini. I then retrieve from the ini file the hotkey and use it in code. The only problem is the hotkeys with modifiers are saving as AHK shorthand, such as ^ for control, and when I try to use this in a script like so:
key = ^2
controlSend, ,%key%, ahk_id %id%
The game will only actually receive the "2". So I wrote a function to remove the ^ and replace with {LControl Down} and {LControl Up} respectively. However it will not work as the follow code throws and illegal character error in the 2nd line "IfInString, ^, input" but I also assume it will in the 4th line.
convertModifier(input) {
IfInString, ^, input
{
output := {LControl Down} . SubStr(input, InStr(input, ^)+1) . {LControl Up}
return output
}
}
I have tried using both ` and \ to escape the ^ but to no luck. Anyone have any ideas?
Thanks alot in advance I appreciate your time.
So Sidola was correct, I had the needle and stack the wrong way around in my IfInString. With a few other bugs worked out, this solution began to work like a dream.
Thanks Sidola.
I'm attempting to send three keys (Alt, Shift, Q) at same time using this script:
:*:pk:: ;
Send, {AltDown}{ShiftDown}{qDown}
return
When I run this is it does not release the keys, it seems like the Alt button remains pressed. After the above keys are pressed I then want to press the "q" character again (separately, not at same time).
How can I amend my script above to achieve this?
When using Down, you must also send an Up to the same key or else it will remain pressed. This can be achieved like this:
:*:pk::
Send, {Alt Down}{Shift Down}{q Down}{Alt Up}{Shift Up}{q Up}
Send, {q}
I use autohotkey to simplify copying, using Alt+W instead of Ctrl+C. However, I often switch my keyboard to a Hebrew layout, so the w key is now the ' key. Then the autohotkey script for w doesn't work.
I tried to write a second script into the same file but it doesn't get activated when I press Alt+' when I'm in the Hebrew layout. I'm not sure whether it's my syntax or something else, any ideas?
This is my code:
!w::
Send, {ctrl down}{a down}{a up}{c down}{c up}{ctrl up}
return
!'::
Send, {ctrl down}{a down}{a up}{c down}{c up}{ctrl up}
return
Thanks!
Catching Alt-' with the code you used works in other keyboard layouts (like the German layout) so your syntax looks OK to me.
To solve your problem I'd start the autohotkey help file.
Read "List of Keys, Mouse Buttons, and Joystick Controls"
where the section on "Special Keys" explains how to attempt
to catch inrecognized keys via the "keyboard hook".
Basically it describes how to find out the !' scancode which
you then can use as a hotkey alternative.
It is worth to try to use the virtual/scan codes of keys, instead names, This example uses the virtual code (vkXX):
;~ SetKeyDelay, keyDelay:=25, pressDuration:=25 ; details for SendEvent mode.
!vk57:: ; w/'/я... (en/he/ru...)
Send, {CtrlDown}{vk41}{vk43}{CtrlUp}
KeyWait, vk57
;~ Do something by release this key, if necessary...
Return