AutoHotKey: make Win+Tab act as Alt+Tab, but remap all other Win+ combinations as Ctrl+ - windows

I am trying to make my MacBook in Windows behave similar to macOS: so I can switch between apps using Win+Tab (i.e., replicate the Alt+Tab action), but have all the Ctrl+... actions (like, Ctrl+C, Ctrl+V, Ctrl+Z, etc) be accessible using the Win key (Win+C, Win+V, Win+Z).
In other words, I am trying to :
Remap Win key to Ctrl in all key combinations, but also
Have the Win+Tab act exactly as Alt+Tab (and I don't care if Ctrl+Tab stops
working as Ctrl+Tab, because I am not using that key combination at
all).
I am able to separately individually achieve 1. using LWin::Ctrl, and 2. using LWin & Tab::AltTab, but I cannot make them work together. Whenever I have something like
LWin::Ctrl
LWin & Tab::AltTab
or
LWin::Ctrl
Ctrl & Tab::AltTab
it just stops working, I am using Windows 10.

Did you try to use the symbols like documented here?
For your snippet that would mean:
LWin::Ctrl
LWin & Tab::Send, !{Tab}
There is a problem with this, as it simulates closed keystokes (regard !{Tab} as {Alt Down}{Tab}{Alt Up}. If you want to press and hold Win and then use Tab (or eventually tab multiple times), this doesn't work. To adress this issue, I found three main workarounds:
)
Let Alt stick to being pressed down:
LWin::Ctrl
LWin & Tab::Send, {Alt Down}{Tab}
LWin & Capslock::Send, {Alt Up} ;Suppose you won't use that hotkey elsewhere
)
Use something this solution by 2501:
h::AltTabMenu ; Opens the menu. Press second time to close.
n::AltTab ; Alt-Tabs through forwards
m::ShiftAltTab ; Alt-Tabs through backwards
The underlying principles/functionalities are documented here.
) Dig into AHK really deep: here (which is referenced in 1)
Annotation: Be aware that
<#::Ctrl
<#Tab::!Tab
does not work as Windows then handles the win key on its own first. You can verify This by testing:
<#::
MsgBox test
return
<#Tab::
MsgBox test
return

Related

Remapping Alt key to Ctrl key in AutoHotKey causes both keys to be pressed

So, just like the title says, whenever I remap my LAlt key to LCtrl (or LCtrl to LAlt) they both get pressed when either key is used, and this causes a variety of issues.
The main reason I need these keys to be swapped is for use with a Mac keyboard on a Windows 7 computer. Honestly, though, it is only the beginning of my problem. I would actually like the LAlt key to be the LCtrl key, the LWin key to be the LAlt key, and the LCtrl key to be the LWin key so it appropriately emulates the Mac keyboard for personal use within Pro Tools 10. When I attempt this 3-way-swap, LCtrl and LWin function properly (as LWin and LAlt respectively), however, the LAlt key continues to press both LCtrl and LAlt anyways.
My code looks like this:
#IfWinActive
LAlt::LCtrl
LWin::LAlt
LCtrl::LWin
Return
I am fairly new to AHK, but this shouldn't be overly complicated, right? It's pretty short and sweet, and I'm not even worried about the Alt+Tab ordeal; I just need to figure out the issue so these three buttons can be swapped correctly. If anyone has any clue as to why this might be happening, I would be profoundly grateful. Thanks for your time and effort.
I think your hotkeys are probably triggering each other.
When you hit LALT, it sends LCTRL, which triggers LALT...
When you have a hotkey whose output matches the input of another hotkey, prefix your hotkeys with $ to stop them triggering each other:
$LAlt::LCtrl
$LWin::LAlt
$LCtrl::LWin
Also, I don't think your #IfWinActive is doing anything, since it has no WinTitle param, plus the return at the end is not how you end an #IfWinActive block, you start it with #IfWinActive <WinTitle> and end it with #IfWinActive

Mapping RightAlt+Ctrl+a to send Ctrl+Delete?

I have the following map:
>!+a::SendInput,+{Delete}
It's supposed to send Ctrl+Delete (delete word after cursor) when I press RightAlt+Ctrl+a but instead it's sending a Ctrl+Alt+Delete signal so it's bringing up the Windows 7 menu of shutdown, start task manager etc.
How can I send the right signal?
Appreciate any help!
The problem you are facing is that Ctrl + Alt + Delete is hard coded and is uninterruptible. There's simply no way around it, if you press that sequence, even with the Command BlockInput enabled, Windows will re-enable input and execute the command...
Try:
>!^a:: ; + symbol is Shift ^ represents Ctrl key
KeyWait, RAlt ; Waits for Right Alt to be released before Ctrl Delete is sent
SendInput,{Ctrl Down}{Delete}{Ctrl Up}
Return
An alternative although it works the exact same way:
>!^a::
While (GetKeyState("RAlt", "P"))
Continue
SendInput,{Ctrl Down}{Delete}{Ctrl Up}
Return
I'll continue to pursue other options.. at the moment I can I think of no better way to do this.

How can I change the keys to change desktop in windows 10 with autohotkey?

Windows 10 has finally multi desktops, you can switch desktops with ctrl+win+right (or left) keys. It's a nice feature, but you have two use two hands to switch desktops.
I'm trying to map the keys like this with autohotkey so I can use just one hand and keep the other one in the mouse..
ctrl + mouse wheel up --> ctrl + win + right
ctrl + mouse wheel down --> ctrl + win + left
the message box comes up so the ctrl + wheel up is working, but it doesn't switches desktops.
~LControl & WheelUp::
MsgBox, Go to desktop right.
Send, {ctrl up}{lwin ctrl righ}
return
~LControl & WheelDown::
MsgBox, Go to desktop left.
Send, {ctrl up}{lwin ctrl left}
return
Any idea why is this not working?.
You can easily switch between two virtual desktops in Windows 10 by using Ctrl+Win+→ or Ctrl+Win+← shortcuts.
But to make this even simpler and easy to use I’ve made this Autohotkey script to toggle betweeen two virtual desktops by just using the (`) key which is the least used key in keyboard.
`::
if (Toggle := !Toggle)
Send #^{right}
else
Send #^{left}
return
Note:- This script works for switching between two desktops only. For creating another virtual desktop you can use the shortcut Ctrl+Win+D.
Inside {} only one key should be specified and I think there's no need for passthrough modifier ~:
LCtrl & WheelUp::Send, {LCtrl up}{LWin down}{LCtrl down}{Right}{LWin up}{LCtrl up}
LCtrl & WheelDown::Send, {LCtrl up}{LWin down}{LCtrl down}{Left}{LWin up}{LCtrl up}
Maybe the standard syntax for modifier keys will also work without sending up-event for LCtrl key:
LCtrl & WheelUp::Send, #{Right}
LCtrl & WheelDown::Send, #{Left}
I know this is an old question but there is now a much better solution that has official support from Microsoft and is really easy to use. Microsoft has recently released an open source tool called Powertoys https://github.com/microsoft/PowerToys . It includes a keyboard manager with a tool for remapping keyboard shortcuts. Its really simple.

Send windows key in vbs?

I've looked everywhere for this, is it actually possible to do? If you press WIN + LEFT ARROW it will mount your selected window to the left of your screen, and that's exactly what I'm trying to do.
I have tried things like:
shl.sendkeys "#{LEFT}"
Because I found out that # could be for WIN just like + is for Shift and % is for Alt.
This may be a stupid question but it would help me out so much. Thank you for you time
Set Keys = CreateObject("WScript.Shell")
Keys.SendKeys("^{Esc}")
This should work, it Simulates the push of the Windows key by pushing the CTRL ^ and the ESC {Esc}keys, i don't know how to make the window mount to the left of the screen
VBScript's SendKeys doesn't support the Windows key.
You can use AutoIt instead:
Send("{#Left}")
Oh, so you want to mount the window to the left, I currently don't think there's a way to do that, but there's another shortcut for start menu, as well as windows key, it's Ctrl+Esc, ^{ESC}, you could possibly run the onscreen keyboard, then somehow tab over to the key, but it would be hard, also how about trying Alt+Space, %{SPACE}, to click the window icon then, M for move, then set the cursors position to the left of the screen, somehow? I don't currently need help moving the cursor in V.B.S., but you could Google it. Hash symbol is actually typing the symbol #, hash, tested with this. I also got help on the send-keys function, here. I have way to much researching, but I still can't find a answer. Some-one also said using "Auto hotkey", a third party program, but I don't really trust programs that can take control over your whole PC.
So I guess your options are:
Alt+Space to click window icon, then M for move, then move cursor to left side of the screen
Auto HotKey, although I don't recommend it.
Other commands, but SendKeys, in VBS,
Running a file, built in a different language to do so.
Or well, waiting-for / asking Microsoft to add it in, in the next version of Windows?!
a very late response, but here is my working effort
Dim shellObject : Set shellObject = CreateObject("WScript.Shell")
Extern.Declare micVoid, "keybd_event", "user32.dll", "keybd_event", micByte, micByte, micLong, micLong
Const KEYEVENTF_KEYUP = &H2
Const VK_LWIN = &H5B
Wait 5
Call Extern.keybd_event(VK_LWIN,0,0,0) 'press win key
Wait 5
shellObject.SendKeys "({UP})" 'right aline the window. TODO Error handlng
Wait 5
Call Extern.keybd_event(VK_LWIN,0,KEYEVENTF_KEYUP,0) 'up win key
Set shellObject = Nothing
try this
wshshell.sendkeys "{lwin}"

Autohotkey remap Apple Mac keyboard on Windows PC

I'm trying to configure an Apple Keyboard with numeric pad to work on a Windows notebook.
I found lots of example and scripts and I was able to remap Cmd to Ctrl and all the functions keys to volume controls, media controls, print screen, etc.
I still can't find a way to move focus to next window (from a program to another): on Windows, this is done by LAtl+Tab, on a Mac by Cmd+Tab. Cmd is remapped to Ctrl but I can't find the Autohotkey command to launch the "move focus to next window" action.
I tried with:
LWin & Tab::SendInput{Alt & Tab}
or
LWin & Tab::Send {Alt & Tab}
but it says that This line does not contain a recognized action.
According to the documentation, a proper syntax would be:
LWin & Tab::SendInput !{Tab}
but nothing happens.
Here is my script:
#InstallKeybdHook
#SingleInstance force
SetTitleMatchMode 2
SendMode Input
F7::SendInput {Media_Prev}
F8::SendInput {Media_Play_Pause}
F9::SendInput {Media_Next}
F10::SendInput {Volume_Mute}
F11::SendInput {Volume_Down}
F12::SendInput {Volume_Up}
LCtrl::LWin
LWin::LCtrl
RWin::RCtrl
F13::SendInput {PrintScreen}
F14::SendInput {ScrollLock}
F15::SendInput {Pause}
Any idea? Thank you.
This should do the trick:
LWin & Tab::AltTab

Resources