un-press the key even if it is being physically pressed on the keyboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

un-press the key even if it is being physically pressed on the keyboard

Post by ibieel » 18 Feb 2024, 12:54

Hey guys, I'm trying to put together a script that does the following:
- If the Shift, Alt or Control key is pressed, un-press the key even if it is being physically pressed on the keyboard.

I made this script:

Code: Select all

#Persistent
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance, Force
SetTimer, label, on


label:
While (GetKeyState("Shift", "P") || GetKeyState("Control", "P") || GetKeyState("Alt", "P")) {
   Send, {Shift Up}
   Send, {Ctrl Up}
   Send, {Alt Up}

   ToolTip, Key is Pressed
}
return


However, I am having the following problem, when the key is being physically pressed (keeping it pressed) the command "Send, {[KEY] Up}" un-press the key for a brief moment but then it is pressed again.

What can I do to fix this?
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: un-press the key even if it is being physically pressed on the keyboard

Post by M4verick » 18 Feb 2024, 13:46

EDIT:

Nevermind - I misunderstood the problem.
Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: un-press the key even if it is being physically pressed on the keyboard

Post by Rohwedder » 19 Feb 2024, 05:32

Hallo,
try:

Code: Select all

#Persistent
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance, Force
Send, {Blind}{Shift Up}{Ctrl Up}{Alt Up}
Shift::Return
Control::Return
Alt::Return
Post Reply

Return to “Ask for Help (v1)”