Buttons remain pressed when I change profile

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Playa 01
Posts: 5
Joined: 28 Apr 2024, 10:39

Buttons remain pressed when I change profile

Post by Playa 01 » 28 Apr 2024, 10:54

Firstly, sorry for my language if i mistake. Because im not English.

I have been using this code for a long time, sometimes i changing:

Code: Select all

profile := 1 ;default
$CapsLock::Profile := 2

#If Profile = 2
$CapsLock::Profile := 1
w::PgUp
s::PgDn
Space::RButton
Shift::Up
LCtrl::Down
Tab::C
RCtrl::LButton
Caps Lock changes the profile. But if I keep pressing a button while changing the profile, the button stays stuck. To fix it, I have to go back to the previous profile and press the button once again. How do I prevent it from being pressed?

Besides, can we make the caps lock key do both profile changing and its own function? I mean, it will both change the profile and turn the caps lock light on and off.

User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Buttons remain pressed when I change profile

Post by mikeyww » 28 Apr 2024, 12:03

Welcome to this AutoHotkey forum!

A few ideas are below.

Code: Select all

#Requires AutoHotkey v1.1.33.11

~*CapsLock Up::SoundBeep 1000 + 500 * GetKeyState("CapsLock", "T")

#If GetKeyState("CapsLock", "T")

LShift::
RShift::
SetKeyDelay 25
While GetKeyState("Shift", "P") & GetKeyState("CapsLock", "T")
 SendEvent {Blind}{Up}
Send {Blind}{Shift up}
Return

#If
If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.

Playa 01
Posts: 5
Joined: 28 Apr 2024, 10:39

Re: Buttons remain pressed when I change profile

Post by Playa 01 » 28 Apr 2024, 15:25

mikeyww wrote:
28 Apr 2024, 12:03
Welcome to this AutoHotkey forum!

A few ideas are below.

Code: Select all

#Requires AutoHotkey v1.1.33.11

~*CapsLock Up::SoundBeep 1000 + 500 * GetKeyState("CapsLock", "T")

#If GetKeyState("CapsLock", "T")

LShift::
RShift::
SetKeyDelay 25
While GetKeyState("Shift", "P") & GetKeyState("CapsLock", "T")
 SendEvent {Blind}{Up}
Send {Blind}{Shift up}
Return

#If
If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.
Thank you for your interest. It normally works, but I usually use it in games and the assigned keys do not react at all in games with your script. If you can write code that will work better in V2, I can use that too.

User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Buttons remain pressed when I change profile

Post by mikeyww » 28 Apr 2024, 15:33

I cannot force the script to work in your game. You could try different hotkeys, or run the script as admin. You could add MsgBox to determine whether you are able to trigger your various hotkeys. If MsgBox works, then the next test could be a one-line script that checks to see whether you can use a hotkey to send any text.

Playa 01
Posts: 5
Joined: 28 Apr 2024, 10:39

Re: Buttons remain pressed when I change profile

Post by Playa 01 » 28 Apr 2024, 15:44

mikeyww wrote:
28 Apr 2024, 15:33
I cannot force the script to work in your game. You could try different hotkeys, or run the script as admin. You could add MsgBox to determine whether you are able to trigger your various hotkeys. If MsgBox works, then the next test could be a one-line script that checks to see whether you can use a hotkey to send any text.
:cry: Okay, thank you.

User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Buttons remain pressed when I change profile

Post by mikeyww » 28 Apr 2024, 16:59

Some games may also require a longer :arrow: press duration.

Due to some of the specialized issues and interests surrounding gaming, this forum has a separate board for gaming.

viewforum.php?f=18

Playa 01
Posts: 5
Joined: 28 Apr 2024, 10:39

Re: Buttons remain pressed when I change profile

Post by Playa 01 » 29 Apr 2024, 11:21

mikeyww wrote:
28 Apr 2024, 16:59
Some games may also require a longer :arrow: press duration.

Due to some of the specialized issues and interests surrounding gaming, this forum has a separate board for gaming.

viewforum.php?f=18
I've tried a lot of things and actually I'm not good at writing code. I think I'll try my luck on the gaming forum.

You are a hero by the way. You've been helping people for years, it's very appreciated.

Post Reply

Return to “Ask for Help (v1)”