Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

FluffyBunnyFeet's profile on WallpaperFusion.com
From an earlier discussion, I copied text that Keith Lammers had provided for having Voicebot continuously presses (presses and hold), until another key is pressed, but that doesn't seem to be working.

Code

using System;
using System.Drawing;

public static class VoiceBotScript
{
    public static void Run(IntPtr windowHandle)
    {
        // Send W continuously
        BFS.Input.SendKeyDown("{VK_87}");
        // loop forever
        while (true)
        {
            // breaks loop if you press any of the following  keys: SHIFT
            if (BFS.Input.IsKeyDown("15"))
                        {
                            BFS.Input.SendKeyUp ( "{VK_87}" );
                            break;
                      };            
            // sleep for a bit so we don't run-up the CPU
            BFS.General.Sleep(50);
        }

       BFS.Input.SendKeyUp ( "{VK_87}" );
    }
}


The code above simply presses "w" once, and stops.
This is for use in the game,. DayZ, for running long distances. I want to just 'aim' and then when needed press a key to stop the running. (I got it to work earlier (continuously press/hold W, but then couldn't get it to stop, no matter what, so I had to exit voicebot.

Any ideas?

Thanks,

Van

EDIT: I've also added in a number of other break keystrokes, none of which work:
====================================
// Send W continuously
BFS.Input.SendKeyDown("{VK_119}");
// loop forever
while (true)
{
if (BFS.Input.IsKeyDown("15")) { BFS.Speech.TextToSpeech("Virtual Key 15 detected down"); BFS.General.Sleep(1250); break; }
if (BFS.Input.IsKeyDown("14")) { BFS.Speech.TextToSpeech("Virtual Key 14 detected down"); BFS.General.Sleep(1250); break; }
if (BFS.Input.IsKeyDown("32")) { BFS.Speech.TextToSpeech("Virtual Key 32 detected down"); BFS.General.Sleep(1250); break;}
====================================

The script, in fact, stays running, no matter which key I press (and I've tried a lot), I have to stop it by cliking the icon in the systray.
Nov 1, 2018 (modified Nov 2, 2018)  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
SendKeyDown is different than how physically holding a key on a keyboard works. When you physically hold a key, the key actually gets repeated (try it in Notepad). SendKeyDown just sets the key state to down once until it's released.

Next week I will do some testing to see if there's a way to script holding the W key in a way that a game would recognize it as a held key.
Nov 2, 2018  • #2
FluffyBunnyFeet's profile on WallpaperFusion.com
Thanks Keith,

unless you come up with a better solution, for now, I'm just going to have an action to "Press key: SHIFT+W", then the macro which waits for a cancelling keypress, then another action to "Release key: SHIFT+W".
it's a little kludgey, but It works.

Thanks,

Van
Nov 3, 2018 (modified Nov 3, 2018)  • #3
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Ok, try the attached script out. It repeats the W key quickly, it's as close as I could get to how it behaves when you hold the key down (test it in notepad if to see what it does). Pressing left shift should stop it from running.
• Attachment: HoldWUntilShiftPressed.txt [542 bytes]
Nov 7, 2018 (modified Nov 7, 2018)  • #4
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)