admin管理员组

文章数量:1401417

I am on Windows 11 and have swapped the Alt and Ctrl keys to emulate keypresses on a MacBook.

Consider the following sequence of keypresses to cut everything and paste, which works:

Alt (Ctrl) + A => (release keys) => Alt (Ctrl) + X => (release keys) => Alt (Ctrl) + V

However, the following doesn't:

Alt (Ctrl) + A => Alt (Ctrl) + X => => Alt (Ctrl) + V

In other words, I need to take my fingers off of the keys for the cut-and-paste to work. How do modify the script to ensure that Alt (Ctrl) pressed at the beginning during Alt (Ctrl) + A persists/sticks with the following commands, such that I could just do the following to achieve the same effect:

Alt (Ctrl) + A => (with Alt (Ctrl) pressed from before) X => (with Alt (Ctrl) pressed from before) V.

Here's the script that I have so far:

#HotKeyInterval 20000
#MaxHotKeysPerInterval 2000

; Swap Left Ctrl and Left Alt
LCtrl::LAlt
LAlt::LCtrl

; Window switching using the new remapped keys (works on hold)
LCtrl & Tab::
    SendInput, !{Tab}  ; Sends Alt + Tab
    return  ; Allows repeated presses without releasing Win

; Move cursor by word using Windows Key
#Left::SendInput, ^{Left}  ; Win + Left Arrow moves one word left
#Right::SendInput, ^{Right}  ; Win + Right Arrow moves one word right

; Delete previous word using Windows + Backspace (works on hold)
#Backspace::
    SendInput, ^{Backspace}  ; Send Ctrl + Backspace
    return  ; Ensures key repeat works properly

; Select Previous/Next Word
#+Left::SendInput, ^+{Left}  ; Win + Shift + Left selects previous word
#+Right::SendInput, ^+{Right}  ; Win + Shift + Right selects next word

#Persistent

I tried a bunch of things, such as adding the below snippet:

LAlt & a::
    SendInput, ^a  ; Ctrl + A (Select All)
    return

LAlt & x::
    SendInput, ^x  ; Ctrl + X (Cut)
    return

LAlt & v::
    SendInput, ^v  ; Ctrl + V (Paste)
    return

But none of those worked. How do I modify the script?

Thanks!

本文标签: autohotkeyHow to make key presses stick from one command to the nextStack Overflow