示例#1
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string             keys;
            ConditionVariables statementvars;

            if (FromString(userdata, out keys, out statementvars))
            {
                string             errlist = null;
                ConditionVariables vars    = statementvars.ExpandAll(ap.functions, statementvars, out errlist);

                if (errlist == null)
                {
                    int    defdelay = vars.Exists(DelayID) ? vars[DelayID].InvariantParseInt(DefaultDelay) : (ap.VarExist(globalvarDelay) ? ap[globalvarDelay].InvariantParseInt(DefaultDelay) : DefaultDelay);
                    string process  = vars.Exists(ProcessID) ? vars[ProcessID] : (ap.VarExist(globalvarProcessID) ? ap[globalvarProcessID] : "");

                    string res = BaseUtils.EnhancedSendKeys.Send(keys, defdelay, DefaultShiftDelay, DefaultUpDelay, process);

                    if (res.HasChars())
                    {
                        ap.ReportError("Key Syntax error : " + res);
                    }
                }
                else
                {
                    ap.ReportError(errlist);
                }
            }
            else
            {
                ap.ReportError("Key command line not in correct format");
            }

            return(true);
        }
示例#2
0
        public bool ExecuteAction(ActionProgramRun ap, BaseUtils.EnhancedSendKeys.AdditionalKeyParser akp)       // additional parser
        {
            string             keys;
            ConditionVariables statementvars;

            if (FromString(userdata, out keys, out statementvars))
            {
                string             errlist = null;
                ConditionVariables vars    = statementvars.ExpandAll(ap.functions, statementvars, out errlist);

                if (errlist == null)
                {
                    int    defdelay            = vars.Exists(DelayID) ? vars[DelayID].InvariantParseInt(DefaultDelay) : (ap.VarExist(globalvarDelay) ? ap[globalvarDelay].InvariantParseInt(DefaultDelay) : DefaultDelay);
                    string process             = vars.Exists(ProcessID) ? vars[ProcessID] : (ap.VarExist(globalvarProcessID) ? ap[globalvarProcessID] : "");
                    string silentonerrors      = vars.Exists(SilentOnError) ? vars[SilentOnError] : (ap.VarExist(globalvarSilentOnErrors) ? ap[globalvarSilentOnErrors] : "0");
                    string announciateonerrors = vars.Exists(AnnounciateOnError) ? vars[AnnounciateOnError] : (ap.VarExist(globalvarAnnounciateOnError) ? ap[globalvarAnnounciateOnError] : "0");

                    string res = BaseUtils.EnhancedSendKeys.Send(keys, defdelay, DefaultShiftDelay, DefaultUpDelay, process, akp);

                    if (res.HasChars())
                    {
                        if (silentonerrors.Equals("2") || (errorsreported.Contains(res) && silentonerrors.Equals("1")))
                        {
                            System.Diagnostics.Debug.WriteLine("Swallow key error " + res);
                            ap.actioncontroller.TerminateAll();
                        }
                        else
                        {
                            errorsreported.Add(res);

                            if (announciateonerrors.Equals("1"))
                            {
                                string culture               = ap.VarExist(ActionSay.globalvarspeechculture) ? ap[ActionSay.globalvarspeechculture] : "Default";
                                System.IO.MemoryStream ms    = ap.actioncontroller.SpeechSynthesizer.Speak("Cannot press key due to " + res, culture, "Default", 0);
                                AudioQueue.AudioSample audio = ap.actioncontroller.AudioQueueSpeech.Generate(ms);
                                ap.actioncontroller.AudioQueueSpeech.Submit(audio, 80, AudioQueue.Priority.Normal);
                            }

                            ap.ReportError(res);
                        }
                    }
                }
                else
                {
                    ap.ReportError(errlist);
                }
            }
            else
            {
                ap.ReportError("Key command line not in correct format");
            }

            return(true);
        }
示例#3
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string             keys;
            ConditionVariables statementvars;

            if (FromString(userdata, out keys, out statementvars))
            {
                string             errlist = null;
                ConditionVariables vars    = statementvars.ExpandAll(ap.functions, statementvars, out errlist);

                if (errlist == null)
                {
                    int    defdelay = vars.Exists(DelayID) ? vars[DelayID].InvariantParseInt(DefaultDelay) : DefaultDelay;
                    string process  = vars.Exists(ProcessID) ? vars[ProcessID] : "";

                    ActionController ac = ap.actioncontroller as ActionController;
                    EliteDangerousCore.BindingsFile bf = ac.DiscoveryForm.FrontierBindings;

                    string res = BaseUtils.EnhancedSendKeys.Send(keys, defdelay, DefaultShiftDelay, DefaultUpDelay, process);

                    if (res.HasChars())
                    {
                        ap.ReportError("Key Syntax error : " + res);
                    }
                }
                else
                {
                    ap.ReportError(errlist);
                }
            }
            else
            {
                ap.ReportError("Key command line not in correct format");
            }

            return(true);
        }
示例#4
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string             say;
            ConditionVariables statementvars;

            if (FromString(userdata, out say, out statementvars))
            {
                string             errlist = null;
                ConditionVariables vars    = statementvars.ExpandAll(ap.functions, statementvars, out errlist);

                if (errlist == null)
                {
                    bool wait = vars.GetInt(waitname, 0) != 0;
                    Audio.AudioQueue.Priority priority = Audio.AudioQueue.GetPriority(vars.GetString(priorityname, "Normal"));
                    string start  = vars.GetString(startname);
                    string finish = vars.GetString(finishname);
                    string voice  = vars.Exists(voicename) ? vars[voicename] : (ap.VarExist(globalvarspeechvoice) ? ap[globalvarspeechvoice] : "Default");

                    int vol = vars.GetInt(volumename, -999);
                    if (vol == -999)
                    {
                        vol = ap.variables.GetInt(globalvarspeechvolume, 60);
                    }

                    int rate = vars.GetInt(ratename, -999);
                    if (rate == -999)
                    {
                        rate = ap.variables.GetInt(globalvarspeechrate, 0);
                    }

                    string culture = vars.Exists(culturename) ? vars[culturename] : (ap.VarExist(globalvarspeechculture) ? ap[globalvarspeechculture] : "Default");

                    bool literal   = vars.GetInt(literalname, 0) != 0;
                    bool dontspeak = vars.GetInt(dontspeakname, 0) != 0;

                    Audio.SoundEffectSettings ses = new Audio.SoundEffectSettings(vars);       // use the rest of the vars to place effects

                    if (!ses.Any && !ses.OverrideNone && ap.VarExist(globalvarspeecheffects))  // if can't see any, and override none if off, and we have a global, use that
                    {
                        vars = new ConditionVariables(ap[globalvarspeecheffects], ConditionVariables.FromMode.MultiEntryComma);
                    }

                    string expsay;
                    if (ap.functions.ExpandString(say, out expsay) != EDDiscovery.ConditionFunctions.ExpandResult.Failed)
                    {
                        if (!literal)
                        {
                            expsay = expsay.PickOneOfGroups(rnd);       // expand grouping if not literal
                        }
                        ap["SaySaid"] = expsay;

                        if ((ap.VarExist("SpeechDebug") && ap["SpeechDebug"].Contains("Print")))
                        {
                            ap.actioncontroller.LogLine("Say: " + expsay);
                            expsay = "";
                        }

                        if (dontspeak)
                        {
                            expsay = "";
                        }

                        System.IO.MemoryStream ms = ap.actioncontroller.DiscoveryForm.SpeechSynthesizer.Speak(expsay, culture, voice, rate);

                        if (ms != null)
                        {
                            Audio.AudioQueue.AudioSample audio = ap.actioncontroller.DiscoveryForm.AudioQueueSpeech.Generate(ms, vars, true);

                            if (audio != null)
                            {
                                if (start != null && start.Length > 0)
                                {
                                    audio.sampleStartTag = new AudioEvent {
                                        apr = ap, eventname = start, triggername = "onSayStarted"
                                    };
                                    audio.sampleStartEvent += Audio_sampleEvent;
                                }
                                if (wait || (finish != null && finish.Length > 0))       // if waiting, or finish call
                                {
                                    audio.sampleOverTag = new AudioEvent()
                                    {
                                        apr = ap, wait = wait, eventname = finish, triggername = "onSayFinished"
                                    };
                                    audio.sampleOverEvent += Audio_sampleEvent;
                                }

                                ap.actioncontroller.DiscoveryForm.AudioQueueSpeech.Submit(audio, vol, priority);

                                return(!wait);       //False if wait, meaning terminate and wait for it to complete, true otherwise, continue
                            }
                            else
                            {
                                ap.ReportError("Say could not create audio, check Effects settings");
                            }
                        }
                    }
                    else
                    {
                        ap.ReportError(expsay);
                    }
                }
                else
                {
                    ap.ReportError(errlist);
                }
            }
            else
            {
                ap.ReportError("Say command line not in correct format");
            }


            return(true);
        }
示例#5
0
 public bool VarExist(string v)
 {
     return(currentvars.Exists(v));
 }
        public void ReadInstallFiles(string folder, string appfolder, string filename, int[] edversion, string itemtype)
        {
            FileInfo[] allFiles = Directory.EnumerateFiles(folder, filename, SearchOption.TopDirectoryOnly).Select(f => new FileInfo(f)).OrderBy(p => p.Name).ToArray();

            foreach (FileInfo f in allFiles)
            {
                try
                {
                    bool?enabled;    // don't care about this in remote files
                    ConditionVariables cv = ReadVarsFromFile(f.FullName, out enabled);

                    if (cv != null)
                    {
                        int[] version;

                        if (cv.Exists("LongDescription") && cv.Exists("ShortDescription") &&
                            cv.Exists("Version") && cv.Exists("Location") &&
                            cv.Exists("MinEDVersion") &&
                            (version = cv["Version"].VersionFromString()) != null
                            )
                        {
                            string installfolder = System.IO.Path.Combine(appfolder, cv["Location"]);
                            string localfilename = System.IO.Path.Combine(installfolder, Path.GetFileName(f.FullName));

                            DownloadItem it = downloaditems.Find(x => x.localfilename.Equals(localfilename, StringComparison.InvariantCultureIgnoreCase));

                            if (it != null)
                            {
                                it.downloadedpath     = folder;
                                it.downloadedfilename = f.FullName;
                                it.downloadedvars     = cv;
                                it.downloadedversion  = version;

                                it.state = (it.downloadedversion.CompareVersion(it.localversion) > 0) ? ItemState.OutOfDate : ItemState.UpToDate;
                            }
                            else
                            {
                                it = new DownloadItem()
                                {
                                    itemname = Path.GetFileNameWithoutExtension(f.FullName),
                                    itemtype = itemtype,

                                    downloadedpath     = folder,
                                    downloadedfilename = f.FullName,
                                    downloadedversion  = version,
                                    downloadedvars     = cv,

                                    localfilename = localfilename,          // set these so it knows where to install..
                                    localpath     = installfolder,

                                    state = ItemState.NotPresent,
                                };

                                downloaditems.Add(it);
                            }

                            int[] minedversion = cv["MinEDVersion"].VersionFromString();

                            if (minedversion.CompareVersion(edversion) > 0)
                            {
                                it.state = ItemState.EDOutOfDate;
                            }
                        }
                    }
                }
                catch { }
            }
        }
示例#7
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string             say;
            ConditionVariables statementvars;

            if (FromString(userdata, out say, out statementvars))
            {
                string             errlist = null;
                ConditionVariables vars    = statementvars.ExpandAll(ap.functions, statementvars, out errlist);

                if (errlist == null)
                {
                    bool wait = vars.GetInt(waitname, 0) != 0;

                    string prior = (vars.Exists(priorityname) && vars[priorityname].Length > 0) ? vars[priorityname] : (ap.VarExist(globalvarspeechpriority) ? ap[globalvarspeechpriority] : "Normal");
                    AudioQueue.Priority priority = AudioQueue.GetPriority(prior);

                    string start  = vars.GetString(startname, checklen: true);
                    string finish = vars.GetString(finishname, checklen: true);
                    string voice  = (vars.Exists(voicename) && vars[voicename].Length > 0)? vars[voicename] : (ap.VarExist(globalvarspeechvoice) ? ap[globalvarspeechvoice] : "Default");

                    int vol = vars.GetInt(volumename, -999);
                    if (vol == -999)
                    {
                        vol = ap.variables.GetInt(globalvarspeechvolume, 60);
                    }

                    int rate = vars.GetInt(ratename, -999);
                    if (rate == -999)
                    {
                        rate = ap.variables.GetInt(globalvarspeechrate, 0);
                    }

                    int queuelimitms = vars.GetInt(queuelimit, 0);

                    string culture = (vars.Exists(culturename) && vars[culturename].Length > 0) ? vars[culturename] : (ap.VarExist(globalvarspeechculture) ? ap[globalvarspeechculture] : "Default");

                    bool literal   = vars.GetInt(literalname, 0) != 0;
                    bool dontspeak = vars.GetInt(dontspeakname, 0) != 0;

                    string prefixsoundpath  = vars.GetString(prefixsound, checklen: true);
                    string postfixsoundpath = vars.GetString(postfixsound, checklen: true);
                    string mixsoundpath     = vars.GetString(mixsound, checklen: true);

                    ConditionVariables  globalsettings = ap.VarExist(globalvarspeecheffects) ? new ConditionVariables(ap[globalvarspeecheffects], ConditionVariables.FromMode.MultiEntryComma) : null;
                    SoundEffectSettings ses            = SoundEffectSettings.Set(globalsettings, vars); // work out the settings

                    if (queuelimitms > 0)
                    {
                        int queue = ap.actioncontroller.AudioQueueSpeech.InQueuems();

                        if (queue >= queuelimitms)
                        {
                            ap["SaySaid"] = "!LIMIT";
                            System.Diagnostics.Debug.WriteLine("Abort say due to queue being at " + queue);
                            return(true);
                        }
                    }

                    string expsay;
                    if (ap.functions.ExpandString(say, out expsay) != ConditionFunctions.ExpandResult.Failed)
                    {
                        if (!literal)
                        {
                            expsay = expsay.PickOneOfGroups(rnd);       // expand grouping if not literal
                        }
                        ap["SaySaid"] = expsay;

                        if ((ap.VarExist("SpeechDebug") && ap["SpeechDebug"].Contains("Print")))
                        {
                            ap.actioncontroller.LogLine("Say: " + expsay);
                            expsay = "";
                        }


                        if (dontspeak)
                        {
                            expsay = "";
                        }

                        System.IO.MemoryStream ms = ap.actioncontroller.SpeechSynthesizer.Speak(expsay, culture, voice, rate);

                        if (ms != null)
                        {
                            AudioQueue.AudioSample audio = ap.actioncontroller.AudioQueueSpeech.Generate(ms, ses, true);

                            if (audio == null)
                            {
                                ap.ReportError("Say could not create audio, check Effects settings");
                                return(true);
                            }

                            if (mixsoundpath != null)
                            {
                                AudioQueue.AudioSample mix = ap.actioncontroller.AudioQueueSpeech.Generate(mixsoundpath);

                                if (mix == null)
                                {
                                    ap.ReportError("Say could not create mix audio, check audio file format is supported and effects settings");
                                    return(true);
                                }

                                audio = ap.actioncontroller.AudioQueueSpeech.Mix(audio, mix);     // audio in MIX format
                            }

                            if (prefixsoundpath != null)
                            {
                                AudioQueue.AudioSample p = ap.actioncontroller.AudioQueueSpeech.Generate(prefixsoundpath);

                                if (p == null)
                                {
                                    ap.ReportError("Say could not create prefix audio, check audio file format is supported and effects settings");
                                    return(true);
                                }

                                audio = ap.actioncontroller.AudioQueueSpeech.Append(p, audio);        // audio in AUDIO format.
                            }

                            if (postfixsoundpath != null)
                            {
                                AudioQueue.AudioSample p = ap.actioncontroller.AudioQueueSpeech.Generate(postfixsoundpath);

                                if (p == null)
                                {
                                    ap.ReportError("Say could not create postfix audio, check audio file format is supported and effects settings");
                                    return(true);
                                }

                                audio = ap.actioncontroller.AudioQueueSpeech.Append(audio, p);         // Audio in P format
                            }

                            if (start != null)
                            {
                                audio.sampleStartTag = new AudioEvent {
                                    apr = ap, eventname = start, ev = ActionEvent.onSayStarted
                                };
                                audio.sampleStartEvent += Audio_sampleEvent;
                            }

                            if (wait || finish != null)        // if waiting, or finish call
                            {
                                audio.sampleOverTag = new AudioEvent()
                                {
                                    apr = ap, wait = wait, eventname = finish, ev = ActionEvent.onSayFinished
                                };
                                audio.sampleOverEvent += Audio_sampleEvent;
                            }

                            ap.actioncontroller.AudioQueueSpeech.Submit(audio, vol, priority);

                            return(!wait);       //False if wait, meaning terminate and wait for it to complete, true otherwise, continue
                        }
                    }
                    else
                    {
                        ap.ReportError(expsay);
                    }
                }
                else
                {
                    ap.ReportError(errlist);
                }
            }
            else
            {
                ap.ReportError("Say command line not in correct format");
            }


            return(true);
        }