help with Capslock as a hotkey trigger

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

help with Capslock as a hotkey trigger

Post by ibieel » 02 Jul 2023, 16:35

hey guys, can you help me?
I made this script, it works fine:

Code: Select all

; CONFIGS
Delay := 50		;delay to dash
Coordinates_SQM_North	:= [956, 254]
Coordinates_SQM_South	:= [958, 502]
Coordinates_SQM_West	:= [831, 378]
Coordinates_SQM_East	:= [1080, 378]

; Global ================================================================================
#KeyHistory 0
SetMouseDelay, -1
SetKeyDelay, -1
CoordMode, Mouse, Screen
SendMode, Input ; Recommended for new scripts due to its superior speed and reliability
#SingleInstance, Force ; Allow only one running instance of script
#Persistent ; Keep script permanently running until terminated


#If, GetKeyState("CapsLock", "P")
~w::
	Click, % Coordinates_SQM_North[1] " " Coordinates_SQM_North[2] " Right"
	Sleep % Delay
RETURN
~s::
	Click, % Coordinates_SQM_South[1] " " Coordinates_SQM_South[2] " Right"
	Sleep % Delay
RETURN
~a::
	Click, % Coordinates_SQM_West[1] " " Coordinates_SQM_West[2] " Right"
	Sleep % Delay
RETURN
~d::
	Click, % Coordinates_SQM_East[1] " " Coordinates_SQM_East[2] " Right"
	Sleep % Delay
RETURN
however it only works if I press Caps + wasd (capslock pressed before wasd). in case I wanted it to ALSO work when I press wasd + caps (press capslock after wasd). How could I make it work in both cases simultaneously?
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: help with Capslock as a hotkey trigger

Post by mikeyww » 02 Jul 2023, 16:48

Hello,

Have a look at custom combinations.
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: help with Capslock as a hotkey trigger

Post by ibieel » 02 Jul 2023, 17:16

mikeyww wrote:
02 Jul 2023, 16:48
Hello,

Have a look at custom combinations.
It's not quite what I need.
if using:

Code: Select all

capslock & w::
I would need to press both at the same time.
I want to be able to press wasd and then capslock without being both at the same time and it works.

It would be like this:
if wasd and capslock are pressed = run the script
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: help with Capslock as a hotkey trigger

Post by mikeyww » 02 Jul 2023, 17:41

Code: Select all

#Requires AutoHotkey v1.1.33
SetCapsLockState AlwaysOff

CapsLock::SetCapsLockState % !GetKeyState("CapsLock", "T")

~w & CapsLock::
CapsLock & ~w::
SoundBeep 1500
Return
Post Reply

Return to “Ask for Help (v1)”