Swap left CTRL with left WIN in Win 11 - sometimes stuck

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kboom
Posts: 5
Joined: 01 Mar 2022, 14:17

Swap left CTRL with left WIN in Win 11 - sometimes stuck

Post by kboom » 29 Apr 2024, 08:24

Hi,
I'm using mac layout keyboard. I really hate using my pinky finger for control so I prefer using my thumb.
I'd like to simply switch both keys.
Right now I have this script which mosty works. Mostly.

Code: Select all

;OPTIMIZATIONS START
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
DllCall("ntdll\ZwSetTimerResolution","Int",5000,"Int",1,"Int*",MyCurrentTimerResolution) ;setting the Windows Timer Resolution to 0.5ms, THIS IS A GLOBAL CHANGE
;OPTIMIZATIONS END

if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}

LWin::LCtrl
LCtrl::LWin
RWin::RAlt

!`::
WinGet, ActiveProcessName, ProcessName, A
WinGet, WinClassCount, List, ahk_exe %ActiveProcessName%

if (WinClassCount = 1)
    return

if (NextWindow = "")
    NextWindow := 2

element := % WinClassCount%NextWindow%

WinSet, Top,, ahk_id %element%
WinActivate, ahk_id %element%

NextWindow += 1

if (NextWindow > WinClassCount || !getKeyState("Alt"))
    NextWindow := 2

return

; Google Search select text - Ctrl + Shift + G
 ^+g::
 {
  Send, ^c
  Sleep 50
  Run, http://www.google.com/search?q=%clipboard%
  Return
 }
return

; ADO Search select text - Ctrl + Shift + A
 ^+a::
 {
  Send, ^c
  Sleep 50
  Run, https://dev.azure.com/mseng/AzureDevOps/_search?text=%clipboard%
  Return
 }
return
However, it is quite usual that it "gets stuck" so that windows key appears to be "sticky pressed" (sticky feature is OFF in my windows); when I press numbers on my keyboard like 1 it would bring up corresponding tools.
To make it unstuck I need to randomly hit windows and control... not exactly sure how it gets stuck on unstuck.
This is super annoying. Could someone please help me with the right script?

I am using windows 11.

[Mod edit: Moved from 'Scripts and Functions (v1)' since this is a help request.]

RussF
Posts: 1285
Joined: 05 Aug 2021, 06:36

Re: Swap left CTRL with left WIN in Win 11 - sometimes stuck

Post by RussF » 29 Apr 2024, 09:09

I believe your question was answered by @mikeyww when you posted it here in the V2 section two days ago. The solution posted should work in either version.

Russ

Post Reply

Return to “Ask for Help (v1)”