Autohotkey: How to remap CTRL with Alt key and - autohotkey

I would like to switch the keys
ALT and CTRL
as well as add
Alt Down keys together to behave the same as Alt Tab
I have tried with the following script but each works by its own, but not together!
; !!!!!!!!!!!! THIS IS WHAT IS ADDED TO THE STANDARD SCRIPT !!!!!!!!!!!!!!
LAlt & Down::AltTab
LAlt::LCtrl
I am using AutoHotkey v1.1.13.01. It is not the latest because I can't use the latest one for a reason.
Shouldn't this work?

I tried this
LAlt & Down::AltTab
LAlt::LCtrl
LCtrl::LAlt
and on my Windows7 system Alt &Ctrl are switched
and Alt & Down works, too.

Related

Creating a hotkey with backslash in AutoHotkey

I want to create a hotkey using a backslash key (\). Namely, I would like to assign Media_Prev to Windows button + backslash. I have tried both LWin & \::Media_Prev and #\::Media_Prev. However, these do not work: it just normally sends the backslash character. In AutoHotkey's key history, I do see that both \ and LWin register when I press this key combination.
Interestingly, something like LWin & c::Media_Prev or #v::Media_Prev does work well, just not with the backslash character.
This worked for me, using AHK version 1.1.13.01
LWin & \:: run Notepad
you can also use scan codes - something like
SC15B & SC02B:: run Notepad
should have the same effect
reference: here
I successfully tested the following:
<#vk dc::Send {Media_Prev}
< is Left key
# is Windows key
VK DC is virtual key number DC (you can find this code using AHK menu View > Key History and Script Info). With VK, the same key works regardless of active keyboard layout.
Note: Don't do LWin & key or Ctrl & key etc... & has a bit different meaning. For the above purpose AHK provides prefixes as shown above, e.g. ^b or #F1 etc. See AHK help on Remapping Keys and Buttons

AutoHotKey: Change keyboard layout by pressing both shift keys

I have used Linux and KDE for a long time and my muscle memory wants to switch keyboard layouts by pressing both shift keys simultaneously. Can I use AutoHotKey to implement that on Windows?
I lack two pieces of information:
How do I remap "both shift keys pressed at the same time"? I can use + to capture the pressing of one shift key, but how about both?
How can I send the key combination that Windows uses to switch layouts (Ctrl+Shift in my current setup)? More generally, how can I remap something to a key combination?
Use combo key notation and L/R prefix, see the documentation (or the help file):
LShift & RShift::send {LShift down}{LCtrl down}{LShift up}{LCtrl up}
I wanted to disable native Windows hotkey altogether. The following works well so far, including console windows.
~RShift & ~LShift::
~LShift & ~RShift::
INPUTLANGCHANGE_FORWARD := 0x2
WM_INPUTLANGCHANGEREQUEST := 0x0050
WinGet, windows, List
Loop % windows {
PostMessage WM_INPUTLANGCHANGEREQUEST, INPUTLANGCHANGE_FORWARD, % Lan, , % "ahk_id " windows%A_Index%
}
return

Using AutoHotKey scripting language is it possible to swap Alt and Ctrl keys and also retain native AltTab key behaviour?

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

In Eclipse Emacs mode, is there any way to remap or add the Alt key to the Esc key?

I'm used to the Emacs use of Esc for Metakey. In eclipse may I change the Esc key to be the Alt key?
Nope, I don't think there's a way to do that. The relevant Eclipse UI docs state:
The recognized modifiers keys are M1, M2, M3, M4, ALT, COMMAND, CTRL, and SHIFT.
ESC is only a "normal" key. Emacs handles ESC specifically, so that it acts like kind of a modifier.
On windows plateform you can use AutoHotkey to remap Esc to Alt
Just add this to your Autohotkey script :
#IfWinActive ahk_class SWT_Window0
$Esc::Alt
#IfWinActive
you may need to adjust the first line to match the class of your Eclipse window (use the windows spy tool provided in Autohokey).

How can I simulate the Windows Key in Autohotkey

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!