Page 1 of 1

How to make my code work

Posted: 09 Aug 2022, 21:57
by Mikaellpc
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 913 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")
}

Re: How to make my code work  Topic is solved

Posted: 09 Aug 2022, 22:07
by boiler

Code: Select all

        Send "{" key " down}"

Same for the other one.

Re: How to make my code work

Posted: 09 Aug 2022, 22:29
by Mikaellpc
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")
}

Re: How to make my code work

Posted: 09 Aug 2022, 22:38
by boiler
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.