How can I simulate the Windows Key in Autohotkey - 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!

Related

How can I remap ctrl+c to ctrl+c in Autohotkey when the buttons (Win, Ctrl, Alt) are blocked in scancode map registry?

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

Shortcuts key replacemento with AutoHotkey

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}

Autohotkey: binding win key

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

Autohotkey: How to remap CTRL with Alt key and

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.

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