I've got a keyboard without the Win key (a legendary Model M!), so I want to bind it to ctrl + esc.
I tried those things, but that doesn't work -_-
LCtrl & Escape::LWin
or
LCtrl & Escape::
Send {LWin}
return
If I simply do:
Escape::LWin
or
Escape::
Send {LWin}
return
It's OK...
I also got another function that works OK like this:
^!F2::Send {Volume_Up 100}
So right now, can't figure what's wrong... Probably the misuse with the "&"?
Any idea?
Thank you!
After answer 1: I found this solution if I want to use the win key for combination (Win + e, Win + d, etc.):
^Esc::
KeyWait Ctrl ;wait until Ctrl is up
Send {LWin Down} ;send left Windows key down
sleep, 500
Send {LWin Up} ;send left Windows key up
Return
That way, when I depress ctrl, I've got 500ms to type the 2nd key.
The problem is that you if you press Ctrl+Esc, then
LWin is sent by AHK, but you are still holding down Ctrl so the result of this 'cooperation' is Ctrl+LWin which is ignored by Windows.
Solution:
^Esc::
KeyWait Ctrl ;wait until Ctrl is up
Send {LWin} ;send left Windows key
Return
Related
I have two AutoHotkey scripts that enable the use of the Ctrl key on both sides of my laptop's keyboard:
Map Caps Lock to (left) Ctrl:
SetCapsLockState, Off
CapsLock::LCtrl
Map Enter to (right) Ctrl when pressed down; otherwise (if no timeout) send Enter:
Enter::RCtrl
~Enter Up::Send % "{RCtrl up}" (A_PriorKey = "Enter" ? "{Enter}" : "")
The two scripts work perfectly with almost no edge cases.
However, I'm unable to trigger Ctrl + Enter, which is a shortcut that I usually use to open a new line on my text editor. Pressing down Caps Lock and hitting Enter, nothing happens. Even if I press down (left)Ctrl (the real key) and hit Enter, nothing happens as well.
What should I do to enable both scripts to work together in order to enable Ctrl + Enter?
I managed to solve the problem in two steps:
Natively map CapsLock to Control. AutoHotkey thinks my CapsLock key is indeed the Control key, which exempts me from handling weird CapsLock on/off edge cases within AutoHotkey.
Use the following script to map Enter as dual-function RCtrl/Enter:
LShift & Enter Up::
GetKeyState, state, Shift
if (A_PriorKey = "Enter" and state = "D") {
Send +{Enter}
}
Send {LCtrl Up}{RCtrl Up}
Return
LCtrl & Enter Up::
GetKeyState, state, Control
if (A_PriorKey = "Enter" and state = "D") {
Send ^{Enter}
}
Send {LCtrl Up}{RCtrl Up}
Return
LAlt & Enter Up::
GetKeyState, state, Alt
if (A_PriorKey = "Enter" and state = "D") {
Send !{Enter}
}
Send {LCtrl Up}{RCtrl Up}
Send {LAlt Up}{RAlt Up}
Return
Enter::RCtrl
~Enter Up::
Send % "{RCtrl up}" ((A_PriorKey = "Enter") ? "{Enter}" : "")
It's super exciting because it works very well! The modifier dance between CapsLock and Enter as symmetric control keys is perfect and I can seamlessly alternate between both sides without nasty edge cases, unexpected modifier presses, releases, or {Enter} presses. The order of the declarations is very important for that to work; the edge cases must come first.
However, as you can see, it is necessary to explicitly handle Alt + Enter, Ctrl + Enter, and Shift + Enter. If I ever need Ctrl + Alt + Enter, I will need to handle that as well.
I wonder if there's a better way to make that work without having to define these additional mappings.
I've tryied on Libreoffice Writter, where CTRL+ENTER go to the next page..
The above code worked fine.
Just added ~ before Enter::RCtrl to not block native function from Enter key.
SetCapsLockState, Off
CapsLock::LCtrl
~Enter::RCtrl
~Enter Up:: Send % "{RCtrl up}" (A_PriorKey = "Enter" ? "{Enter}" : "")
P.S:
And i think you may use only one script with both instructions, instead of using one script for each..
I have my keyoard CTRL button blocked in scancode map registry, but in the other side I need to enable the combination ctrl+c and ctrl+v for the administrator, So I wrote this part of code but it's not working:
^c::
Send, ^c
return
What do you think I can do to resolve this issue?
FYI : I've tried also to add $ before ^c to be able to send the same combination
If you have the CTRL button blocked, ^c:: will not be detected. Try an alternative such as this.....
!c:: ; This is ALT C
Keywait, %A_ThisHotkey% ; Waits for the above hotkey to be released.
Send, ^c
return
Pressing the CTRL+Numpad 7 key, it displays the text I want, but the CTRL key remains pressed.
How do I prevent it from being pressed after executing the command?
My AutoHotKey code is something like this
Ctrl & Numpad7::
SendInput `
(
some text
multiline
)
return
I had the same problem and I fixed it with this something like this :
!Crtl Up:: send {Ctrl Down}
try this in the end of the script(the line after return).
Currently I must Ctrl & Tab to perform a traditional AltTab.
I've already swapped my Alt and Ctrl keys. However, I still want to be able to AltTab traditionally
This is what I have so far:
LCtrl::Alt
Alt::LCtrl
LCtrl & Tab::AltTab
LCtrl & Tab::Send {Alt Down}{Tab}{Alt Up}
Is the simple answer and will switch between the last 2 open windows.
If you want proper functionality, you'll have to read:
http://www.autohotkey.com/docs/commands/GetKeyState.htm
and use it in conjuction with
GetKeyState, OutputVar, LCtrl
If OutputVar = "D"
Send {Tab}
etc
This is works for me
LControl & Tab::AltTab
I have an old IBM Model M from 1994. It's awesome, but it doesn't have a Windows key. I'd like to use AutoHotkey to map the combination of Ctrl + Alt to simulate the Windows key in order to take advantage of the default Windows shortcuts. Here's what I have:
LCtrl & LAlt :: Send {LWin}
It was suggested that maybe windows is overriding the Ctrl + Alt combo, so I also tried:
~Alt & Space :: Send {LWin}
Neither of these work. I'd at least like to be able to open the Start Menu from the keyboard (Ctrl + Esc is too awkward.)
It seems the windows key is not working as long as either ctrl or alt is pressed. The following script works for me:
<^LAlt::
KeyWait Alt
KeyWait Ctrl
Send {RWin}
return
<!LCtrl::
KeyWait Alt
KeyWait Ctrl
Send {RWin}
return
You can press the left Ctrl and left alt in any order, and when you release both, the windows key is generated. This way you will not be able to send combination like Windows-E. If you want that too, you can do something like:
<^<!e::
KeyWait Alt
KeyWait Ctrl
Send {RWin down}e{RWin up}
return
<^<!space::
KeyWait Alt
KeyWait Ctrl
Send {RWin}
return
Now press leftctrl-leftalt-e to genereate windows-e, and press leftctrl-leftalt-space for just the windows key.
I'm also using an IBM Model M. I've mapped RCtrl to the RWin key using KeyTweak (in Windows 7 and XP).
You can get KeyTweak here: KeyTweak homepage
(you can edit directly your registry but it's much easier to use the above program).
With this approach you can continue to use Win+R, Win+Tab (in Windows 7), Win+E, etc. and your Autohotkey scripts will also detect your RCtrl keypresses as RWin.
Try this:
Ctrl & Q::send {LWin}
Someone suggested that I make my comment an answer.
I did very similar to what wimh did above, but I removed the KeyWait commands. Normal keyboard hotkeys don't wait until you have all of your fingers lifted off of the keys, you can press the hotkey combination and then hold the keys down, and have the action still occur. The >^>! and <^<! make the command work with either the left or the right Alt and Ctrl keys.
; Open explorer
>^>!e::
Send #e
return
<^<!e::
Send #e
return
; Lock workstation, #L and downLup don't work
>^>!L::
DllCall("LockWorkStation")
return
<^<!L::
DllCall("LockWorkStation")
return
; Run dialog
<^<!r::
Send {RWin down}r{RWin up}
return
>^>!r::
Send {RWin down}r{RWin up}
return
I'm not sure why some key combinations you can use #, but others like the Run dialog require you to RWin down, press r, then RWin up. This must be a quirk with Windows.
I've uploaded my autohotkey.ahk file to Github, if anyone is interested!