Author Topic: Toggle key pressing at set interval?  (Read 2941 times)

adora

  • Newbie
  • *
  • Posts: 26
Toggle key pressing at set interval?
« on: June 14, 2021, 08:49:37 AM »
Hey Everyone!

Super new to this program and coding in general. Thanks in advance for your patience. ;D

I am looking for help to automate skill casting on a popular arpg...

bind a key [q]
Press [q] at [10s] intervals.
pressing the key again will cancel the function.

I tried to play around with the toggle but couldn't figure out how to set this up :(

As well are there any visual cues I can use to show on the screen when it is active/not active. Green/red dot maybe? some text somewhere, etc?

Thanks!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: Toggle key pressing at set interval?
« Reply #1 on: June 14, 2021, 09:19:49 AM »
I am looking for help to automate skill casting on a popular arpg...
Which "arpg", specifically?

As well are there any visual cues I can use to show on the screen when it is active/not active. Green/red dot maybe? some text somewhere, etc?
Not as an overlay, no. If you have a second monitor, you could display VoiceAttack's main window on it and show a message in the log, though newer log messages could push it off the visible list

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #2 on: June 14, 2021, 09:27:53 AM »
Diablo?

**and thanks for letting me know about the second screen option :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: Toggle key pressing at set interval?
« Reply #3 on: June 14, 2021, 10:28:10 AM »
Do make sure that automating a keypress in this manner does not violate the EULA or any other policies of the application you are targeting.

Using VoiceAttack in a manner that risks it getting flagged as undesirable by any anti-cheat system cannot be tolerated, and would jeopardize the future of the application.



One possible option is a command like this:
Code: [Select]
Begin Text Compare : [{CMDALREADYEXECUTING}] Equals '1'
    Kill command, '<name of this command>' (by name)
End Condition
Start Indefinite Loop
    Press Q key and hold for 0,06 seconds and release
    Pause 10 seconds
End Loop

If another instance of the command is already running, the condition will kill both instances (note that the instance with the pause may take a while to show its "Stopped command" message in the log, as it'll only check whether it needs to stop and the end of said pause for performance reasons).

You need to enter the name of the command (or a phrase that would trigger the command, if there are multiple) into the "Stop by name" field of the "Stop Another Command" action.

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #4 on: June 14, 2021, 11:58:27 AM »
I wholesomely respect this project and look forward to staying within the ToS and EULA of the applications I am working with.  8)

This function to auto-cast is already widely accepted as a non-bannable offense in this 10+ year-old game using the
"numlock" trick. -> https://www.youtube.com/watch?v=JaAI8s8rft4

Due to keyboard settings (you need to have a number pad physically on your keyboard) and its awkward use case (it prevents you from typing talking in-game) I have opted to find a better way.

Although there are many discussions on the topic mostly over the last 5 years and up about this specific trick my observations are these.

The use of macros likely falls under Section 1, C, ii, and COULD considered a form of automation at best. Sadly my cramping old man hands aren't what they used to be.

However, in this case, I am pressing the same button repeatedly literally aimlessly smashing the buttons. If the game was all about button smashing endurance (like using an auto clicker to get clicks faster to win) I would agree this would be automating the main function and likely be cheating.

There are no combos here like League for automating the timing of multiple keys. It does not improve my god-given ability to aim, move or play the game. Just making the game more accessible to people that aren't professional keyboard smashing twitch players. ::)

That being said, I'm only using it on "smashable keys" since the game actually has skill shots and timed buffs that would require my human brain to decide on its timing and use case.

Lastly, I have been using the num lock trick for about 4 years now and have not been banned or know anyone that has been banned for this reason. Not that this would prove that it's okay but because Blizzard has never told the community directly and so this may offer some insight to the idea that they don't care since they still actively remove cheaters in almost every season for botting/cheating.



adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #5 on: June 14, 2021, 12:01:12 PM »
As for the script, it does do its job but I can't seem to cancel it.
simply add more loops to increase the duration of the press.  :'(

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: Toggle key pressing at set interval?
« Reply #6 on: June 14, 2021, 12:03:11 PM »
Which version of VoiceAttack are you running?


What does your action list look like?
Right-click the action list, choose "Copy All as Text" from the context menu, then paste here into a code block (click the # button)

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #7 on: June 14, 2021, 12:56:26 PM »
2:42:44.881 UNABLE TO KILL COMMAND, '[autocast r]' (by name). COMMAND NOT AVAILABLE.

Steam 64-bit 1.8.8

Code: [Select]
Begin Text Compare : [{CMDALREADYEXECUTING}] Equals '1'
    Kill command, '[autocast r]' (by name)
End Condition
Start Indefinite Loop
    Press R key and hold for 0.5 seconds and release
    Pause 1 second
End Loop

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: Toggle key pressing at set interval?
« Reply #8 on: June 14, 2021, 12:59:39 PM »
Square brackets in the "When I say" field denote a dynamic command section, meaning they are removed from the actual command phrase.

The phrase itself would be "autocast r"

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #9 on: June 14, 2021, 01:09:00 PM »
Thanks so much!

I look forward to learning so much more.

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #10 on: June 14, 2021, 11:00:25 PM »
If I wanted to do this to the LMB and RMB I'll need to activate "left shift/force stand" before clicking the mouse button. This will tell the game to processes the activatable skill instead of the movement.

What would be the best way to achieve this?




Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: Toggle key pressing at set interval?
« Reply #11 on: June 15, 2021, 01:44:59 AM »
As in, how would you instruct VoiceAttack to press shift before pressing the mouse button, and release it again after releasing the mouse button?

Two keypress actions, one set to "Press Key(s)", the other set to "Release Key(s)", E.G.
Code: [Select]
Press down Left Shift key
Click left mouse button
Release Left Shift key

Note that pressing the Shift key will have the same effect as manually pressing it, I.E. it can affect any controls it otherwise would while the key is down

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #12 on: June 15, 2021, 08:21:46 AM »
Ahhh ty!

I think I wasn't respecting the order of execution (is that even a real thing?)

Code: [Select]
Press and hold down the key for x seconds
then<- press LMB

When I really wanted to have the button pressed and held while clicking the MB.

I did try recording the complete set of movements but it didn't seem to record the mouse clicks just movement if I wanted. Is this correct or was I overlooking something?

So thanks for showing me da way!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: Toggle key pressing at set interval?
« Reply #13 on: June 15, 2021, 09:12:23 AM »
I think I wasn't respecting the order of execution (is that even a real thing?)
Yes, actions are executed in the order they are encountered in the action list, unless you're making use of control flow actions.

More information on the latter principle can be found here: Control flow (If, Else, ElseIf, Loop, Jump) basics

And in general, this can also be useful in addition to the official documentation: Variables and tokens summed up


I did try recording the complete set of movements but it didn't seem to record the mouse clicks just movement if I wanted. Is this correct or was I overlooking something?
Did you press the relevant hotkey to enable mouse click/wheel capture? The default would be F7

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #14 on: June 15, 2021, 09:32:56 AM »
Thanks for the great links to awesome resources.

I went back to play around with the recorder and learned that if my mouse is in the recording window it does not record the mouse click but does however record the mouse wheel. neat.  8)

I imagine this is to maintain access to the recording options.

looks like I know 2 ways to succeed no, so thanks!

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #15 on: June 17, 2021, 09:58:56 AM »
Due to the interaction mechanics for this application, I've had to tweak some of the key presses to hold key press. as a result the application does allow me to interact in the appropriate way but as you might see the keypress never ends.

Code: [Select]
Begin Text Compare : [{CMDALREADYEXECUTING}] Equals '1'
    Kill command, 'skill 1' (by name)
    Release 1 key
End Condition
Start Indefinite Loop
    Press down 1 key
End Loop

I did play around with this but either it performs multiple clicks and thus breaks the desired interaction or it works but I can't stop the loop without running a separate kill command.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: Toggle key pressing at set interval?
« Reply #16 on: June 17, 2021, 10:25:47 AM »
As set up in your example, the command is continuously spamming that keypress, which you indicate is not the intent.

What input are you actually trying to generate? What does the target application require?

adora

  • Newbie
  • *
  • Posts: 26
Re: Toggle key pressing at set interval?
« Reply #17 on: June 17, 2021, 10:56:32 AM »

I got it ::).
Probably needed more coffee last night when I was looking at it.

It's here for anyone that may find it useful.

Code: [Select]
Begin Text Compare : [{CMDALREADYEXECUTING}] Equals '1'
    Release 1 key
    Kill command, 'skill 1' (by name)
End Condition
Start Indefinite Loop
    Press down 1 key
End Loop