/// <summary> /// SDK initializer which should be called one time only on first script call. /// </summary> public static void Initialize() { ContextOptions.Initialize(); Scanner.Initialize(); TileReader.Initialize(); ScriptLogger.Initialize(); }
/// <summary> /// Code handled by Thread. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ScriptThread_DoWork(object sender, DoWorkEventArgs e) { // Stores "Thread" to var var worker = (BackgroundWorker)sender; // Invokes Thread safe Actions onto UI. In this case disable play button , enable stop button. Invoke((MethodInvoker) delegate { tsbplay.Enabled = false; }); Invoke((MethodInvoker) delegate { tsbstop.Enabled = true; }); //Enables logger methods from SDK ScriptLogger.Initialize(); //Initializes Loggin Event, wich performs an action whenever ScriptLogger gets new Logfiles. ScriptLogger.OnLogging += ScriptLogger_OnLogging; //Sample loop to repeat code inside, until thread gets stopped or application closed. while (!worker.CancellationPending) { //Sends Text to Logger, wich shares it onto UI through event. ScriptLogger.WriteLine("Hello Thread!"); // Let the thread sleep when not requiring actions. Thread.Sleep works better then "Waits" via Api-Call. Thread.Sleep(500); } // Invokes Thread safe Actions onto UI. In this case disable stop button, enable play button. Invoke((MethodInvoker) delegate { tsbplay.Enabled = true; }); Invoke((MethodInvoker) delegate { tsbstop.Enabled = false; }); }
public static void Run() { ScriptLogger.Initialize(); ScriptLogger.LogToStealth = true; if (ValidateConfig()) { try { var data = xmlconfig.Parse(); Stealth.Client.UseObject(data.ContainerID); while (Stealth.Client.GetLastContainer() != data.ContainerID) { Stealth.Client.Wait(data.WaitDelay); } if (Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, data.ContainerID, true) > 0) { var r = Stealth.Client.GetFindList(); var l = new List<string>(); foreach (var e in r) { Stealth.Client.ClickOnObject(e); var t = string.Empty; while (t.Trim() == "") t = Stealth.Client.GetTooltip(e, data.ToolTipDelay); l.Add(e + ";" + t.Replace("|", ";")); } File.WriteAllLines(data.FileName, l); } } catch (Exception) { ScriptLogger.WriteLine("Error on Export Handling!"); } } else { ScriptLogger.WriteLine(string.Format("Unable to find {0}", cfgname)); } }