Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?
Save up to 50% on our desktop apps during our Year End Sale!Save up to 50% on our desktop apps during our Year End Sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save up to 50% on our desktop apps during our Year End Sale!

User Image
DAB42
31 discussion posts
I have one macro I want to start and keep running all the time. I do not want to have more them one copy of it running.

I have tried using a second macro to lunch the first one as follows with no success. it does work if I just want to it tell we if the program is already working, but if I lunch the never ending program "elite log reader " it will not close and report it running.

Code

using System;
using System.Drawing;

public static class VoiceBotScript
{
    public static void Run(IntPtr windowHandle)
    {
        if(BFS.VoiceBot.IsMacroRunning("elite log reader"))
        {
        BFS.Speech.TextToSpeech("log reader is already running");
        }
        else
        {
         BFS.VoiceBotActions.RunMacro("elite log reader");
             }
        
    }
}
Jul 16, 2018  • #1
User Image
DAB42
31 discussion posts
has there been any progress on this problem of not allowing a script to run twice?
Jul 25, 2018  • #2
User Image
megawatt
8 discussion posts
You can use a while loop like this:

Code

using System;
using System.Drawing;

public static class VoiceBotScript
{
    public static void Run(IntPtr windowHandle)
    {
        while (true)
        {
            BFS.VoiceBotActions.RunMacro("elite log reader");
        }
     }
}


I haven't tried it but this should make it run forever.
Jul 25, 2018 (modified Jul 25, 2018)  • #3
User Image
DAB42
31 discussion posts
the macro already runs continuously. I want to be able prevent more then one copy from running.

The is running fails
Jul 26, 2018  • #4
User Image
megawatt
8 discussion posts
Try this:

Code

using System;
using System.Drawing;

public static class VoiceBotScript
{
    public static void Run(IntPtr windowHandle)
    {
        while (BFS.VoiceBot.IsMacroRunning("elite log reader"))
        {
        BFS.Speech.TextToSpeech("log reader is already running");
        }

         BFS.VoiceBotActions.RunMacro("elite log reader");
        
    }
}
Jul 26, 2018  • #5
User Image
DAB42
31 discussion posts
Thank you for the effort megawatt but the issue seems to be with the way the run macro code works on continuously ruining macros.

The following works when the run macro command is not used. but fails when launching the "elite log reader" which is kept running with an infinite while loop. the following code results in both macros running without closings and a new copy of both macros started each time you call this macro.

Code

using System;
using System.Drawing;
using System.Threading;

public static class VoiceBotScript
{
    //public static bool ranOnce = false;

    public static void Run(IntPtr windowHandle)
    {
        if(!BFS.VoiceBot.IsMacroRunning("elite log reader"))
        {
             BFS.Speech.TextToSpeech("log reader is not running");
             //BFS.VoiceBotActions.RunMacro("elite log reader");
             }
        else
            {
         BFS.Speech.TextToSpeech("log reader is running");
            }
            
    }
        
}
Jul 26, 2018  • #6
Thomas Malloch (BFS)'s profile on WallpaperFusion.com
Have you considered using Window Properties? If you set a window property in Elite: Dangerous' window when you run the script, you can be sure that the script has run once. Then, when the game shuts down and starts back up again, the window property won't be there, so your script will know that it needs to be run. I've provided some example code below :).

Code

public static void Run(IntPtr windowHandle)
{
    // If the window property is IntPtr.Zero, it doesn't exist. Run the script, and create the property
    if( BFS.Window.GetWindowProperty(windowHandle, "IsEliteLogRunnerRunning") == IntPtr.Zero )
    {
        BFS.Window.SetWindowProperty(windowHandle, "IsEliteLogRunnerRunning", new IntPtr(1));
        BFS.Speech.TextToSpeech("log reader is not running");
        //BFS.VoiceBotActions.RunMacro("elite log reader");
    }
    else
    {
        BFS.Speech.TextToSpeech("log reader is running");
    }
}


Thanks!
Aug 13, 2018  • #7
User Image
DAB42
31 discussion posts
Thank you Works perfectly.

As I am not a programmer so I can only guess this works where script settings fails because it saves outside of voicebot?

no mater works great thank you very much.
Aug 15, 2018  • #8
Thomas Malloch (BFS)'s profile on WallpaperFusion.com
You're exactly right!

Instead of trying to keep track of whether or not it was the same window, this script saves a value to the window in question. That way we know for sure if we've run the script on the game or not.

Thanks!
Aug 15, 2018  • #9
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)