private void Plugin_OnUserAction(IRecordPlugin sender, IRecordEvent e) { vm.Plugin.Stop(); OpenRPA.Input.InputDriver.Instance.onCancel -= OnCancel; e.ClickHandled = true; // GenericTools.restore(GenericTools.mainWindow); GenericTools.Restore(this); vm.Selector = e.Selector; vm.FocusElement(e.Selector); vm.NotifyPropertyChanged("json"); // e.Element }
private void Plugin_OnUserAction(IRecordPlugin sender, IRecordEvent e) { OnCancel(); // OpenRPA.Input.InputDriver.Instance.CallNext = true; e.ClickHandled = true; GenericTools.Restore(this); vm.Selector = e.Selector; vm.json = vm.Selector.ToString(); vm.FocusElement(e.Selector); vm.NotifyPropertyChanged("json"); // e.Element }
internal void OnPlay(object _item) { Workflow workflow = null; if (_item != null && _item is Workflow) { workflow = _item as Workflow; } if (SelectedContent is Views.AgentViewProjects view) { if (view != null) { var val = view.listWorkflows.SelectedValue; if (val == null) { return; } if (!(view.listWorkflows.SelectedValue is Workflow wf)) { return; } workflow = wf; } } if (workflow != null) { string errormessage = ""; try { GenericTools.Minimize(); IWorkflowInstance instance; var param = new Dictionary <string, object>(); instance = workflow.CreateInstance(param, null, null, IdleOrComplete, null, null, null); instance.Run(); } catch (Exception ex) { errormessage = ex.Message; Log.Error(ex.ToString()); } if (Config.local.notify_on_workflow_end && !string.IsNullOrEmpty(errormessage)) { App.notifyIcon.ShowBalloonTip(1000, "", errormessage, System.Windows.Forms.ToolTipIcon.Error); GenericTools.Restore(); } else if (!string.IsNullOrEmpty(errormessage)) { GenericTools.Restore(); MessageBox.Show("onPlay " + errormessage); } return; } }
internal void OnUninstall(object _item) { IsBusy = true; Task.Run(async() => { try { BusyContent = "Initializing"; var minver = VersionRange.Parse(SelectedPackageItem.InstalledVersion); var identity = new PackageIdentity(SelectedPackageItem.Id, minver.MinVersion); if (project.dependencies == null) { project.dependencies = Newtonsoft.Json.Linq.JObject.Parse("{}"); } project.dependencies.Remove(identity.Id); // per project or joined ? // string TargetFolder = System.IO.Path.Combine(project.Path, "extensions"); string TargetFolder = System.IO.Path.Combine(Interfaces.Extensions.ProjectsDirectory, "extensions"); BusyContent = "Uninstalling package"; NuGetPackageManager.Instance.UninstallPackage(TargetFolder, identity); SelectedPackageItem.IsInstalled = false; BusyContent = "Saving current project settings"; await project.Save(false); //BusyContent = "Updating NuGet Packages"; //await project.InstallDependencies(); //BusyContent = "Reloading Activities Toolbox"; //GenericTools.RunUI(() => WFToolbox.Instance.InitializeActivitiesToolbox()); SelectedPackageItem.InstalledVersion = ""; SelectedPackageItem.IsInstalled = false; if (NuGetPackageManager.PendingDeletion.Count > 0) { Config.local.files_pending_deletion = NuGetPackageManager.PendingDeletion.ToArray(); Config.Save(); MessageBox.Show("Please restart the robot for the change to take fully effect"); } if (SelectedPackageSource.source == null) { SelectedPackageSource.ClearCache(); GenericTools.RunUI(() => { FilterText = FilterText; }); } } catch (Exception ex) { Log.Error(ex.ToString()); } IsBusy = false; }); }
private void button_OK_Click(object sender, EventArgs e) { bool Authenticated = AnalystConnection.Login(textBox_UserName.Text, textBox_UserPass.Text); if (Authenticated) { label_InfoPanel.Text = "Conectando ao SKF @ptitude Analyst..."; this.Update(); /* * Process AnalystExe = new Process(); * AnalystExe.StartInfo.FileName = AppFileName; * AnalystExe.StartInfo.Arguments = AppParams; * AnalystExe.Start(); * * INIFile.Write(GenericTools.WindowsGetUserName(), "LastProcessId", AnalystExe.Id); */ this.Close(); } else if (AnalystConnection.SQLtoString("Passwd", "UserTbl", "LoginName='" + textBox_UserName.Text + "'") == AnalystConnection.NoPassword) { if (button_OK_FirstClick) { button_OK_FirstClick = false; textBox_UserName.Enabled = false; button_OK_FirstPass = textBox_UserPass.Text; textBox_UserPass.Text = string.Empty; label_InfoPanel.Text = "Configurando nova senha para usuário." + Environment.NewLine + "Repita a nova senha, por favor."; } else { button_OK_FirstClick = true; textBox_UserName.Enabled = true; label_InfoPanel.Text = "Digite suas informações de login."; if (button_OK_FirstPass != textBox_UserPass.Text) { MessageBox.Show("As senhas digitadas não conferem."); } else { AnalystConnection.SQLUpdate("UserTbl", "Passwd", GenericTools.PassEncode(textBox_UserPass.Text), "LoginName='" + textBox_UserName.Text + "'"); button_OK_Click(sender, e); } } } else { label_InfoPanel.Text = "Usuário ou senha da aplicação incorretos." + Environment.NewLine + "Verifique seus dados de login e tente novamente."; } this.Update(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Task.Run(() => { var treeelements = vm.Plugin.GetRootElements(vm.Anchor); GenericTools.RunUI(this, () => { Log.Debug("init selector model, with " + treeelements.Count() + " root elements"); vm.init(treeelements); // vm.FocusElement(vm.Selector); }); }); }
public void init() { try { if (PluginConfig.auto_launch_java_bridge) { EnsureJavaBridge(); } if (pipeclient == null) { var SessionId = System.Diagnostics.Process.GetCurrentProcess().SessionId; pipeclient = new NamedPipeClient <JavaEvent>(SessionId + "_openrpa_javabridge"); pipeclient.ServerMessage += Pipeclient_ServerMessage; pipeclient.Connected += Pipeclient_Connected; pipeclient.Disconnected += Pipeclient_Disconnected; pipeclient.AutoReconnect = true; pipeclient.Start(); } if (Initilized) { return; } GenericTools.RunUI(() => { Initilized = false; _windowCache = new HwndCache(); Log.Debug("javahook.init()"); accessBridge.Initilized += (e1, e2) => { Initilized = true; Log.Information("javahook._accessBridge.Initilized"); OnInitilized?.Invoke(accessBridge); }; if (IntPtr.Size == 4) { // accessBridge.Initialize(true); accessBridge.Initialize(false); } else { accessBridge.Initialize(false); } refreshJvms(200); }); } catch (Exception ex) { Log.Error(ex.ToString()); } }
public void onIdleOrComplete(WorkflowInstance instance) { Log.Debug("onIdleOrComplete state: " + instance.state); if (!string.IsNullOrEmpty(instance.errormessage)) { Log.Error(instance.errormessage); } if (instance.state != "idle") { Console.WriteLine("Workflow " + instance.state + " in " + string.Format("{0:mm\\:ss\\.fff}", instance.runWatch.Elapsed)); GenericTools.restore(GenericTools.mainWindow); } OnIdleOrComplete?.Invoke(instance, EventArgs.Empty); }
private void NotifyState() { GenericTools.RunUI(() => { try { Workflow.NotifyPropertyChanged("State"); Workflow.NotifyPropertyChanged("StateImage"); } catch (Exception) { } }); }
public void SetLastState(string State) { if (State == "loaded") { return; } if (laststate != State) { //Task.Run(() => //{ // if (State != "idle" && State != "running") // { // if (lastSaveTime.AddSeconds(5) < DateTime.Now || true) // { // Task.Run(async () => // { // try // { // // await Save(true); // await Save<Workflow>(true); // } // catch (Exception ex) // { // Log.Error(ex.ToString()); // } // }); // lastSaveTime = DateTime.Now; // } // } // laststate = State; // GenericTools.RunUI(() => NotifyUIState()); //}); laststate = State; if (State != "idle" && State != "running") { Task.Run(async() => { try { await Save <Workflow>(true); } catch (Exception ex) { Log.Error(ex.ToString()); } }); } GenericTools.RunUI(() => NotifyUIState()); } }
protected override void StartLoop(NativeActivityContext context) { Interfaces.VT.ITerminalSession session = null; var timeout = Timeout.Get(context); if (Timeout == null || Timeout.Expression == null) { timeout = TimeSpan.FromSeconds(3); } string WorkflowInstanceId = context.WorkflowInstanceId.ToString(); GenericTools.RunUI(() => { // termOpen3270Config Config = new termOpen3270Config(); Config.Hostname = Hostname.Get(context); Config.TermType = TermType.Get(context); Config.Port = Port.Get(context); session = RunPlugin.GetRecorderWindow(Config); if (string.IsNullOrEmpty(session.WorkflowInstanceId)) { session.WorkflowInstanceId = WorkflowInstanceId; } context.SetValue(_elements, session); if (!HideUI.Get(context)) { session.Show(); } if (session.Terminal == null || !session.Terminal.IsConnected) { session.Connect(); } }); var sw = new Stopwatch(); sw.Start(); while (!session.Terminal.IsConnected && sw.Elapsed < timeout) { System.Threading.Thread.Sleep(50); } Log.Output(string.Format("Connected to {0} in {1:mm\\:ss\\.fff}", session.Config.Hostname, sw.Elapsed)); if (!session.Terminal.IsConnected) { throw new Exception("Timeout connecting to " + Hostname.Get(context) + ":" + Port.Get(context)); } session.Refresh(); context.ScheduleAction(Body, session, OnBodyComplete); }
public void IdleOrComplete(IWorkflowInstance instance, EventArgs e) { if (string.IsNullOrEmpty(instance.caller)) { return; } if (!RunWorkflowInstances.ContainsKey(instance.caller)) { return; } if (instance.isCompleted || instance.Exception != null) { var _instance = RunWorkflowInstances[instance.caller]; if (instance.Parameters != null) { _instance.Result = instance.Parameters; } else { _instance.Result = new Dictionary <string, object>(); } RunWorkflowInstances.Remove(instance.caller); if (!string.IsNullOrEmpty(instance.errormessage)) { _instance.Error = new Exception(instance.errormessage); } if (instance.Exception != null) { _instance.Error = instance.Exception; } _instance.Pending.Set(); GenericTools.RunUI(() => { // if ran in designer, call IdleOrComplete to break out of debugging and make designer not readonly var designer = global.OpenRPAClient.GetWorkflowDesignerByIDOrRelativeFilename(_instance.IDOrRelativeFilename); try { if (designer != null) { designer.IdleOrComplete(instance, e); } } catch (Exception) { } }); } }
private void onRecord(object item) { if (!(item is Views.WFDesigner)) { return; } var designer = (Views.WFDesigner)item; designer.lastinserted = null; designer.lastinsertedmodel = null; InputDriver.Instance.OnKeyDown += OnKeyDown; InputDriver.Instance.OnKeyUp += OnKeyUp; StartRecordPlugins(); InputDriver.Instance.CallNext = false; GenericTools.minimize(GenericTools.mainWindow); }
public void ForceFocus(bool redo = true) { Activate(); Focus(); Topmost = true; Topmost = false; rtbConsole.Focus(); if (redo) { Task.Run(async() => { await Task.Delay(500); GenericTools.RunUI(() => ForceFocus(false)); }); } }
/// <summary>Returns a dictionary that contains the handle and title of all the open windows.</summary> /// <returns>A dictionary that contains the handle and title of all the open windows.</returns> public static IDictionary <IntPtr, InfoWindow> GetOpenedWindows(bool includeHidden, bool includeEmptyTitle) { IntPtr shellWindow = GetShellWindow(); Dictionary <IntPtr, InfoWindow> windows = new Dictionary <IntPtr, InfoWindow>(); EnumWindows(new EnumWindowsProc(delegate(IntPtr hWnd, int lParam) { try { if (hWnd == shellWindow) { return(true); } if (!includeHidden) { if (!IsWindowVisible(hWnd)) { return(true); } } int length = GenericTools.GetWindowTextLength(hWnd); string Title = ""; if (length == 0) { if (!includeEmptyTitle) { return(true); } } else { StringBuilder builder = new StringBuilder(length); GenericTools.GetWindowText(hWnd, builder, length + 1); Title = builder.ToString(); } var info = new InfoWindow(); info.Handle = hWnd; info.File = new System.IO.FileInfo(GetProcessPath(hWnd)); info.Title = Title; windows[hWnd] = info; } catch (Exception) { } return(true); }), 0); return(windows); }
protected override void Execute(NativeActivityContext context) { var filename = Filename.Get(context); GenericTools.RunUI(() => { try { var f = new Playback(filename); f.ShowDialog(); } catch (Exception ex) { Log.Error(ex.ToString()); } }); }
public void StartRecording() { if (IsRecording) { throw new InvalidOperationException("Already recording."); } IsRecording = true; GenericTools.RunUI(() => { lastFileName = System.IO.Path.Combine(outputFolder, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".avi"); var bitRate = Mp3AudioEncoderLame.SupportedBitRates.OrderBy(br => br).ElementAt(audioQuality); recorder = new Recorder(lastFileName, encoder, encodingQuality, audioSourceIndex, audioWaveFormat, encodeAudio, bitRate); }); }
private void OnBodyComplete(NativeActivityContext context, ActivityInstance completedInstance) { var session = _elements.Get(context); if (session == null) { return; } string WorkflowInstanceId = context.WorkflowInstanceId.ToString(); if (session.WorkflowInstanceId != WorkflowInstanceId) { return; } session.Disconnect(); GenericTools.RunUI(session.Close); RunPlugin.Sessions.Remove(session); }
public void init() { try { if (Initilized) { return; } GenericTools.RunUI(() => { Initilized = false; _windowCache = new HwndCache(); Log.Debug("javahook.init()"); accessBridge.Initilized += (e1, e2) => { Initilized = true; Log.Information("javahook._accessBridge.Initilized"); OnInitilized?.Invoke(accessBridge); }; try { if (IntPtr.Size == 4) { // accessBridge.Initialize(true); accessBridge.Initialize(false); } else { accessBridge.Initialize(false); } refreshJvms(200); } catch (Exception ex) { Log.Error(ex.ToString()); } }); } catch (Exception ex) { Log.Error(ex.ToString()); } }
private void onIdle(WorkflowInstance instance, EventArgs e) { if (!string.IsNullOrEmpty(instance.queuename) && !string.IsNullOrEmpty(instance.correlationId)) { RobotCommand command = new RobotCommand(); var data = JObject.FromObject(instance.Parameters); command.command = "invoke" + instance.state; command.workflowid = instance.WorkflowId; command.data = data; _ = global.webSocketClient.QueueMessage(instance.queuename, command, instance.correlationId); } else { if (instance.state != "idle") { GenericTools.restore(GenericTools.mainWindow); } } }
// https://stackoverflow.com/questions/1567017/com-object-that-has-been-separated-from-its-underlying-rcw-cannot-be-used public void Disconnect() { if (!Connected) { return; } try { if (form != null && !form.Disposing) { GenericTools.RunUI(form, () => { try { if (rdpConnection != null && rdpConnection.Connected == 1) { rdpConnection.Disconnect(); } } catch (Exception ex) { Log.Error(ex.ToString()); } }); } } catch (Exception ex) { Log.Error(ex.ToString()); } try { if (rdpConnection != null && rdpConnection.Connected == 1) { rdpConnection.Disconnect(); } } catch (Exception) { throw; } Dispose(); }
private async void onPlay(object item) { if (!(item is Views.WFDesigner)) { return; } var designer = (Views.WFDesigner)item; if (designer.HasChanged) { await designer.Save(); } GenericTools.minimize(GenericTools.mainWindow); var param = new Dictionary <string, object>(); await designer.Workflow.Run(param, null, null, onIdle); return; }
public void StartRecording(FourCC encoder, string outputFolder, int encodingQuality, string filename = null) { if (IsRecording) { throw new InvalidOperationException("Already recording."); } this.encoder = encoder; this.outputFolder = outputFolder; this.encodingQuality = encodingQuality; string extension = ".avi"; if (encoder != KnownFourCCs.Codecs.Uncompressed && encoder != KnownFourCCs.Codecs.MotionJpeg) { extension = ".mpeg"; } if (!System.IO.Directory.Exists(outputFolder)) { System.IO.Directory.CreateDirectory(outputFolder); } GenericTools.RunUI(() => { try { if (string.IsNullOrEmpty(filename)) { filename = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); } lastFileName = System.IO.Path.Combine(outputFolder, filename + extension); var bitRate = Mp3AudioEncoderLame.SupportedBitRates.OrderBy(br => br).ElementAt(audioQuality); recorder = new Recorder(lastFileName, encoder, encodingQuality, audioSourceIndex, audioWaveFormat, encodeAudio, bitRate); IsRecording = true; } catch (Exception ex) { Log.Error(ex.ToString()); } }); }
public bool WaitForText(string Text, TimeSpan Timeout) { if (string.IsNullOrEmpty(Text)) { return(true); } try { var sw = new Stopwatch(); sw.Start(); do { foreach (var field in emulator.Screen.Strings) { if (!string.IsNullOrEmpty(field.Text)) { if (field.Text.Contains(Text)) { return(true); } } } foreach (var field in emulator.Screen.Fields) { if (!string.IsNullOrEmpty(field.Text)) { if (field.Text.Contains(Text)) { return(true); } } } System.Threading.Thread.Sleep(250); GenericTools.RunUI(Refresh); } while (sw.Elapsed < Timeout); return(false); } finally { GenericTools.RunUI(Redraw); } }
public void CleanUp(ref IWorkflowInstance e) { if (!PluginConfig.auto_close) { return; } foreach (var sesion in Sessions) { if (sesion.WorkflowInstanceId == e.InstanceId) { try { GenericTools.RunUI(sesion.Close); } catch (Exception) { } } } }
private void OnKeyDown(Input.InputEventArgs e) { if (!isRecording) { return; } if (e.Key == KeyboardKey.Escape) { StopRecordPlugins(); InputDriver.Instance.CallNext = true; InputDriver.Instance.OnKeyDown -= OnKeyDown; InputDriver.Instance.OnKeyUp -= OnKeyUp; GenericTools.restore(GenericTools.mainWindow); return; } // if (e.Key == KeyboardKey. 255) return; try { if (mainTabControl.SelectedContent is Views.WFDesigner view) { if (view.lastinserted != null && view.lastinserted is Activities.TypeText) { Log.Debug("re-use existing TypeText"); var item = (Activities.TypeText)view.lastinserted; item.AddKey(new Activities.vKey((FlaUI.Core.WindowsAPI.VirtualKeyShort)e.Key, false), view.lastinsertedmodel); } else { Log.Debug("Add new TypeText"); var rme = new Activities.TypeText(); view.lastinsertedmodel = view.addActivity(rme); rme.AddKey(new Activities.vKey((FlaUI.Core.WindowsAPI.VirtualKeyShort)e.Key, false), view.lastinsertedmodel); view.lastinserted = rme; } } } catch (Exception ex) { Log.Error(ex.ToString()); } }
public void StopRecording() { if (!IsRecording) { throw new InvalidOperationException("Not recording."); } GenericTools.RunUI(() => { try { if (recorder != null) { recorder.Dispose(); recorder = null; } } finally { IsRecording = false; } }); }
private void Browser_LoadingStateChanged(object sender, CefSharp.LoadingStateChangedEventArgs e) { var CookieManager = CefSharp.Cef.GetGlobalCookieManager(); //cookieManager = Browser.GetCookieManager(); if (!e.IsLoading) { CookieManager.VisitAllCookiesAsync().ContinueWith(t => { if (t.Status == TaskStatus.RanToCompletion) { string cookies = ""; var browsercookies = t.Result; foreach (var cookie in browsercookies) { System.Diagnostics.Debug.WriteLine("CookieName: " + cookie.Name); if (cookie.Domain == new Uri(this.url).DnsSafeHost) { cookies += cookie.Name + "=" + cookie.Value + "; "; } } if (!string.IsNullOrEmpty(cookies)) { // System.Diagnostics.Debug.WriteLine(getjwt(this.url, cookies)); _jwt = getjwt(this.url, cookies); if (!string.IsNullOrEmpty(_jwt)) { GenericTools.RunUI(() => { DialogResult = true; }); } } } else { System.Diagnostics.Debug.WriteLine("No Cookies found"); } }); } }
public async Task Upload() { if (Context.Message.Attachments.Any()) { try { var msg = await Context.Channel.SendMessageAsync($"{Context.Message.Author.Mention} Téléchargement en cour..."); await GenericTools.HandleFile(Context.Message.Attachments.First(), Context.Message.Author.Mention); await msg.ModifyAsync(x => x.Content = $"{Context.Message.Author.Mention} Personnage uploadé avec succès"); } catch (Exception ex) { await Context.Channel.SendMessageAsync($"Could not download file.{Environment.NewLine}{ex.Message}"); } } else { await Context.Channel.SendMessageAsync("File not found. Please upload an Excel file while using this command."); } }
public bool doHighlight() { HighlightImage = Extensions.GetImageSourceFromResource(".x.png"); NotifyPropertyChanged("HighlightImage"); // IElement[] results = new IElement[] { }; Task.Run(() => { var results = new List <IElement>(); if (Anchor != null) { var _base = Plugin.GetElementsWithSelector(Anchor, null, 10); foreach (var _e in _base) { var res = Plugin.GetElementsWithSelector(Selector, _e, maxresult); results.AddRange(res); } } else { var res = Plugin.GetElementsWithSelector(Selector, null, maxresult); results.AddRange(res); } GenericTools.RunUI(() => { foreach (var element in results) { element.Highlight(false, System.Drawing.Color.Red, TimeSpan.FromSeconds(1)); } if (results.Count() > 0) { HighlightImage = Extensions.GetImageSourceFromResource("check.png"); NotifyPropertyChanged("HighlightImage"); } }); }); // return (results.Count() > 0); return(true); }