How to remap Caps Lock to Win key? - autohotkey

I have an IBM Model M keyboard that doesn't have a Win key, and I'd like to remap CapsLock using Autohotkey.
Ideally, I'd like to remap all possible combinations at once (eg. CapsLock->Windows) rather than having to treat each combination in a seaprate line (eg. CapsLock+Shift+W -> Win+Shift+W)
The script below works for simple key combos, like Win+R.
*Capslock::Send "{LWin down}"
*Capslock Up::Send "{LWin up}"
But it's not working when I press down multiple modifier keys, for example Win+Shift+W.
The simple remap below also isn't working for combined modifiers:
Capslock::LWin
If I open On Screen Keyboard, remove focus, and press down CapsLock and L-Alt, it shows me both Win and L-Alt are pressed.
Pressing the thrid key, for example W, would not be shown by On Screen Keyboard even when using a real Win key on another keyboard.

Related

Re-enable right-Ctrl when using Canadian Multilingual Standard keyboard for my AutoHotkey function?

I have an Autohotkey function that lets me switch between tabs with "Control + left/right" as well as closing tabs (Ctrl-down) and going into the search bar (Ctrl-up). It helps me save clicks and use the mouse less.
However, I use the Canadian Multilingual Standard keyboard to type accents (éèçà) in French for some of my classes and this keyboard DISABLES the right control key (the one right beside my keyboard buttons) which is the most convenient to use with my right hand only.
Here is a source documenting this: http://archives.miloush.net/michkap/archive/2013/04/08/10409187.html
Is there any way I can override this? I very rarely use the letter œ for because I can just use ALT + 0156 instead.
Here is the very simple code for my hotkey!
^Left::SendInput, ^{PGUP}
^Right::SendInput, ^{PGDN}
^Up::SendInput, !d
^Down::SendInput, ^w
Using SciTE4AutoHotkey tool, on my UK hardware keyboard right ctrl is detected as expected (RControl)
When I switch to French (Canada) Canadian Multilingual keyboard,
the right ctrl key is not found, also Virtual Key is different: DF
(SC means scan code and VK means virtual key)
so if you remap, it should solve the problem
~SC11D::RControl
After remapping: not found is replaced by RControl with each keypress.
Even if above remapping does not work for your case, it is a matter of finding which key corresponds to relevant scan code and then you can remap it.
Double click on your ahk script on the taskbar, and then
View > Key history and script info (Ctrl + K) by pressing key and refresh(F5) you can see respective keyboard scan codes.

How do Bind a key or mouse click to the fn key (autohotkey)

So I am working with an old windows vista and to decrease the volume you need to press fn + the up or down arrow key. I'm stuck trying to figure out how to find the key for the fn key but some of the methods I try don't work. I want to bind it to the mouse scroll, the normal soundset doesn't work for some reason the computer is an acser extenssa 5220. Anymore questions I will answer down bellow. I'm thinking about downloading a program to remap the keys on the vista, but then I still don't if that and autohotkey will work.
You don't send the FN key because Windows doesn't actually even know of such a key. The FN key is processed by your keyboard. So what's sent to Windows is actually just the multimedia key, in your case volume up/down.
In AHK you can send the keys like this: SendInput, {Volume_Up}.
Alternatively you could use SoundSet.

Trying to recognize Fn + V on my keyboard

I hate that when I'm using my laptop on its own I often type FN+v when I mean to paste. So I decided to solve my problem with AHK. I installed a keyboard hook in my main script,and used that to extract the fn keys value, 163. My initial test worked, but adding the & to make it a modifier does not. What am I overlooking?
So this doesn't work
SC163 & v::
MsgBox, %A_ThisHotkey% was pressed.
return
but this did work
SC163::
MsgBox, %A_ThisHotkey% was pressed.
return
When you hit the FN key, it might be remapping the "v" to something else (like "Media_Play_Pause" button) in the keyboard driver. Therefore the key code wouldn't be SC163 & v but something like SC159.
The Special Keys section for mentions a method to get the Scan code:
Ensure that at least one script is running that is using the keyboard hook. You can tell if a script has the keyboard hook by opening its main window and selecting "View->Key history" from the menu bar.
Double-click that script's tray icon to open its main window.
Press one of the "mystery keys" on your keyboard.
Select the menu item "View->Key history"
Scroll down to the bottom of the page. Somewhere near the bottom are the key-down and key-up events for your key. NOTE: Some keys do not generate events and thus will not be visible here. If this is the case, you cannot directly make that particular key a hotkey because your keyboard driver or hardware handles it at a level too low for AutoHotkey to access. For possible solutions, see Special Keys.
If your key is detectable, make a note of the 3-digit hexadecimal value in the second column of the list (e.g. 159).

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

Autokey: Capslock and a character will not map to Left

I'm trying to use Capslock to modify hjkl to arrows to simulate vim but I keep getting an error.
Capslock & h::Left
I get an error:
Line Text: Left
Error: This line does not contain a recognised action
Capslock is later remapped to Esc.
If I use the mapping to fire off a new window it works without fault.
Is there a way to achieve this?
My keyboard doesn't have a left windows key so I cannot use the windows key.
Try this:
Capslock & h::send, {left}
It works for me this way.