How to make my code work Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Mikaellpc
Posts: 2
Joined: 09 Aug 2022, 21:46

How to make my code work

Post by Mikaellpc » 09 Aug 2022, 21:57

I have some problems playing multiversus on pc because Down Normal Attack is very hard to do and I'm trying to make a script to make these actions easier, the purpose of my function is When aKey is pressed then do: ArrowDown Hold, key Hold, ArrowDown Release, Wait for aKey Release, key Release

But when i try to run my script i just get
image.png
image.png (13.61 KiB) Viewed 890 times
Down Attack can be a charged attack so i need to wait the aKey release

Code: Select all

#Requires AutoHotkey v2.0-beta

downCombo(key,aKey){
    if (GetKeyState(aKey)){
        Send "{Down down}"
        Send (key Down)
        Send "{Down up}" 
        while (GetKeyState(aKey)){
            sleep 20
        }
        Send (key Up)
    }
}

Loop{
    WinWaitActive "MultiVersus "
    downCombo("x","z")
    downCombo("c","v")
}

User avatar
boiler
Posts: 17107
Joined: 21 Dec 2014, 02:44

Re: How to make my code work  Topic is solved

Post by boiler » 09 Aug 2022, 22:07

Code: Select all

        Send "{" key " down}"

Same for the other one.

Mikaellpc
Posts: 2
Joined: 09 Aug 2022, 21:46

Re: How to make my code work

Post by Mikaellpc » 09 Aug 2022, 22:29

boiler wrote:
09 Aug 2022, 22:07

Code: Select all

        Send "{" key " down}"

Same for the other one.
I have just one more question, can this if check with a loop I'm using cause performance problems or not?

final version if anyone wants

Code: Select all

#Requires AutoHotkey v2.0-beta

downCombo(key,aKey){
    if (GetKeyState(aKey)){
        ; Check if Down is already active
        if(GetKeyState("Down")){
            Send "{" key " down}"
        }
        else{
            Send "{Down down}"
            Send "{" key " down}"
            Send "{Down up}" 
        }
        while (GetKeyState(aKey)){
            sleep 20
        }
        Send "{" key " up}"
    }
}

Loop{
    WinWaitActive "MultiVersus "
    downCombo("x","z")
    downCombo("c","a")
}

User avatar
boiler
Posts: 17107
Joined: 21 Dec 2014, 02:44

Re: How to make my code work

Post by boiler » 09 Aug 2022, 22:38

Mikaellpc wrote: I have just one more question, can this if check with a loop I'm using cause performance problems or not?
Check your CPU usage using Task Manager. If it's too high, add a Sleep in the loop or use SetTimer with a period that is sufficiently long to keep CPU usage low.

Post Reply

Return to “Ask for Help (v2)”