Author Topic: 2 kb keys to 1 cmd  (Read 1771 times)

adora

  • Newbie
  • *
  • Posts: 26
2 kb keys to 1 cmd
« on: June 16, 2021, 04:37:05 PM »
I felt as if this might be somewhere on the forums but due to my lack of terms couldn't find anything in the forum search.

I've noticed I can use 2 LMB and RMB together to activate a command but unless I am fridge blind I can't see how to do this with keyboard keys.

Ultimately, I'm looking to move around using my keyboard (WASD). Where using W+D, for example, would activate a new direction, instead of fighting over each other. In a perfect world releasing D would allow the function of W to resume seamlessly.

I don't have my controller charged but I imagine there is a feature for binding those "W+D" directions directly to the button?

Thanks again for any help!  ;D :D :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: 2 kb keys to 1 cmd
« Reply #1 on: June 16, 2021, 04:45:58 PM »
You're going to have to elaborate on that.

Move around in what? How would pressing forward (W) and right (D) cause a "fight", rather than diagonal motion? Is it that you specifically don't want diagonal motion?

How does a controller come in to it, and would the intent be to trigger a command using a controller button, or to press a controller button using a command? The latter is not possible as the DirectInput/XInput APIs don't allow it (this is not a VoiceAttack-specific limitation)

adora

  • Newbie
  • *
  • Posts: 26
Re: 2 kb keys to 1 cmd
« Reply #2 on: June 16, 2021, 05:12:17 PM »
Currently, I can move in 4 directions. 8 is where it's at.

Each command is set to move the mouse 300px in a chosen direction from the middle of the screen using the standard WASD keyboard configuration and finally, a click that will move the character. I also have it set to repeat clicking while held to continue to walk in a chosen direction.

Because of the constant clicking when holding, the commands are fighting to go in two directions at the same time. So although I do move in between the two directions it's very janky and the screen being locked to the character basically is ready to seizure me up.

My thought was if I could bind something like this:

w forward - working
a left - working
s right- working
d down - working
w+a up left
a+s left down
s+d down right
d+w right up

The later 4 can actually be their own commands since there are options for setting x,y.

I think I'm looking for a way to tell VoiceAttack that I want to press 2 keys to activate 1 command that neither of those keys possesses alone. (example: you can press mouse 1 or mouse 2 to activate a command where mouse 1 and mouse 2 together have something else completely)

Although I will be looking to implement many things with a controller we can just leave it out of this conversation. Just getting ahead of myself.

Thanks

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: 2 kb keys to 1 cmd
« Reply #3 on: June 16, 2021, 05:29:43 PM »
Does releasing a given direction key return the cursor to the center of the screen?

What does the action list for your "W" command 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: 2 kb keys to 1 cmd
« Reply #4 on: June 16, 2021, 05:38:40 PM »
it returns to where it was before the interaction because I set it to save and restore location.

For each directional key (W,A,S,D) I have

Code: [Select]
Save current mouse location
Move mouse cursor to Active Window Screen Center
Move mouse left [0] pixel(s), up [300] pixel(s) (from cursor position)
Press Space key and hold for 0.01 seconds and release
Recall saved mouse location


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: 2 kb keys to 1 cmd
« Reply #5 on: June 16, 2021, 05:42:30 PM »
Do you have any options enabled that would repeat the command? You mentioned you "have it set to repeat clicking while held"?

adora

  • Newbie
  • *
  • Posts: 26
Re: 2 kb keys to 1 cmd
« Reply #6 on: June 16, 2021, 09:16:29 PM »
I do, but disabling this would not help since I would have to keep smashing the W(up) key to move up. Having it repeat is an easy way to hold the key down it to keep moving steadily in that direction.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4758
  • RTFM
Re: 2 kb keys to 1 cmd
« Reply #7 on: June 16, 2021, 09:52:58 PM »
Instead of trying to herd cats and coordinate a bunch of different commands, I'd use a single command running a loop, that checks the state of the relevant keys, and performs the relevant actions.

The only function of the commands directly triggered by keypresses would be to check whether the loop commands is running, and to start it if not.


E.G.
WASD Manager
Code: [Select]
Save current mouse location
Move mouse cursor to Active Window Screen Center
Start Indefinite Loop
    Begin Device State Check :  Keyboard Key 'W' Is Pressed
        Begin Device State Check :  Keyboard Key 'A' Is Pressed
            Move mouse left [150] pixel(s), up [150] pixel(s) (from cursor position)
        Else If Device State Check :  Keyboard Key 'D' Is Pressed
            Move mouse right [150] pixel(s), up [150] pixel(s) (from cursor position)
        Else
            Move mouse up [300] pixel(s) (from cursor position)
        End Condition
    Else If Device State Check :  Keyboard Key 'S' Is Pressed
        Begin Device State Check :  Keyboard Key 'A' Is Pressed
            Move mouse left [150] pixel(s), down [150] pixel(s) (from cursor position)
        Else If Device State Check :  Keyboard Key 'D' Is Pressed
            Move mouse right [150] pixel(s), down [150] pixel(s) (from cursor position)
        Else
            Move mouse down [300] pixel(s) (from cursor position)
        End Condition
    Else If Device State Check :  Keyboard Key 'A' Is Pressed
        Move mouse left [300] pixel(s) (from cursor position)
    Else If Device State Check :  Keyboard Key 'D' Is Pressed
        Move mouse right [300] pixel(s) (from cursor position)
    Else
        Recall saved mouse location
        Exit Command
    End Condition
    Press Space key and hold for 0,01 seconds and release
End Loop

WASD W, WASD A, WASD S, and WASD D
Code: [Select]
Begin Text Compare : [{CMDACTIVE:WASD Manager}] Equals '0'
    Execute command, 'WASD Manager'
End Condition

Do note that the spacebar keypress adds a 10ms delay to the loop (as it also did in your original repeating command), as the command needs to wait until the key has been pressed and released, so ideally you wouldn't want to increase the hold down time on that too much.


If you have any other commands in mind, I suggest take your time, read through the documentation, and try to put something together. Experimentation is a good way to learn, in my experience.
« Last Edit: June 17, 2021, 09:45:38 AM by Pfeil »

adora

  • Newbie
  • *
  • Posts: 26
Re: 2 kb keys to 1 cmd
« Reply #8 on: June 17, 2021, 09:42:48 AM »
Thanks again Pfeil,

As usual, you have a great solution for this. It was cool to see how you've problem solved your way around this. These are the kind of examples I need to really dive into things so thanks again!