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); }
static public string Menu(Form parent, System.Drawing.Icon ic, string userdata, List <string> additionalkeys, BaseUtils.EnhancedSendKeys.AdditionalKeyParser additionalparser) { ConditionVariables vars; string keys; FromString(userdata, out keys, out vars); ExtendedControls.KeyForm kf = new ExtendedControls.KeyForm(); int defdelay = vars.Exists(DelayID) ? vars[DelayID].InvariantParseInt(DefaultDelay) : ExtendedControls.KeyForm.DefaultDelayID; string process = vars.Exists(ProcessID) ? vars[ProcessID] : ""; kf.Init(ic, true, " ", keys, process, defdelay: defdelay, additionalkeys: additionalkeys, parser: additionalparser); // process="" default, defdelay = DefaultDelayID default if (kf.ShowDialog(parent) == DialogResult.OK) { ConditionVariables vlist = new ConditionVariables(); if (kf.DefaultDelay != ExtendedControls.KeyForm.DefaultDelayID) // only add these into the command if set to non default { vlist[DelayID] = kf.DefaultDelay.ToStringInvariant(); } if (kf.ProcessSelected.Length > 0) { vlist[ProcessID] = kf.ProcessSelected; } return(ToString(kf.KeyList, vlist)); } else { return(null); } }
} // Tell dragger no resizing. public void Init(Icon i, bool showprocess, string separ = " ", // and separ between entries string keystring = "", // current key string string process = "", // empty means program default, return empty back int defdelay = 50, // -1 means program default, return -1 back bool allowkeysedit = false, List <string> additionalkeys = null, BaseUtils.EnhancedSendKeys.AdditionalKeyParser parser = null) { if (i != null) { Icon = i; } seperator = separ; textBoxKeys.Text = keystring; curinsertpoint = keystring.Length; textBoxSendTo.Text = process.Alt(DefaultProcessID); textBoxNextDelay.Text = textBoxDelay.Text = defdelay != DefaultDelayID?defdelay.ToStringInvariant() : "Default"; radioButtonPress.Checked = true; if (additionalkeys != null) { comboBoxKeySelector.Items.AddRange(additionalkeys); } comboBoxKeySelector.Items.AddRange(KeyObjectExtensions.KeyListString()); additionalkeyparser = parser; //System.Diagnostics.Debug.WriteLine(String.Join(",",KeyObjectExtensions.VKeyList())); comboBoxKeySelector.Text = ""; comboBoxKeySelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxKeySelector_SelectedIndexChanged); if (!showprocess) { textBoxNextDelay.Visible = panelRadio.Visible = labelNextDelay.Visible = labelDelay.Visible = textBoxDelay.Visible = labelSendTo.Visible = textBoxSendTo.Visible = buttonTest.Visible = false; int d = textBoxKeys.Top - textBoxDelay.Top; foreach (Control c in new Control[] { buttonReset, buttonDelete, buttonNext, textBoxKeys, labelKeys }) { c.Top -= d; // shift down } d += 40; // cause of the Send foreach (Control c in new Control[] { buttonOK, buttonCancel }) { c.Top -= d; } panelOuter.Height -= d; this.Height -= d; } //System.Diagnostics.Debug.WriteLine("T" + textBoxKeys.Text + " at " + curinsertpoint + " >" + textBoxSendTo.Text); bool border = true; ThemeableForms theme = ThemeableFormsInstance.Instance; if (theme != null) // paranoid { border = theme.ApplyToForm(this); } labelCaption.Visible = !border; AddMF(); if (allowkeysedit) { textBoxKeys.ReadOnly = false; } DisplayKeyString(); }