Dim bar As ProgressBar = New ProgressBar()
bar.Location = New System.Drawing.Point(50, 20)
bar.Name = āprogressBar1ā
bar.Size = New System.Drawing.Size(171, 23)
bar.TabIndex = 0
bar.Style = ProgressBarStyle.Marquee
bar.Minimum = 0
bar.Maximum = 100
frm.Controls.Add(bar)
frm.Show()
Importing System.windows.Forms first is required, note also that you will get no intelisense from it inside the code activity.
However, once the last step of the workflow will finish, the form will disapear.
to test it you can use a message box activty after the code activity to block the thread.
However to do this kind of thing i would rather strongly recommend either using Custom Activities or even making an .exe with visual studio and starting process using the file path, then killing or close mainwindow from once everything is done.
@Florent_Salendres,
Thanks for your post. I agree that a custom activity is better, but Iām struggling to get Invoke Code to do what I want in UiPath, so this is more an exercise in doing that.
I imported System.Windows.Forms, and pasted your code (without mods) into an Invoke Code window.
I added a message box to block the thread. (When that failed, I tried with System.Reflection, also without success.)
Can you point out to me where Iām going wrong, if you have time? Iāve attached screenshots and the .xaml I used.
Best regards and thanks in advance,
burque505
.xaml: Main.xaml (9.1 KB)
You were pretty close, just some small change to make on the code first:
Dim formsA As AssemblyReference=System.Reflection.Assembly.LoadWithPartialName(āSystem.Windows.Formsā) Using formsA
Dim frm As Form = New Form
Dim bar As ProgressBar = New ProgressBar()
bar.Location = New System.Drawing.Point(50, 20)
bar.Name = āprogressBar1ā
bar.Size = New System.Drawing.Size(171, 23)
bar.TabIndex = 0
bar.Style = ProgressBarStyle.Marquee
bar.Minimum = 0
bar.Maximum = 100
frm.Controls.Add(bar)
frm.Show() End Using
Remove part in bold, We will use another way to import except the New just before progressBar that you will need to add
Then we will need to import Namespace using the āImportā Panel (close to the variable panel on the bottom and look for System.Windows.Forms and click it when it appears on the drop-down.
The last step, in order to have it functional, you need to create a variable under the variable panel, with a type coming from WindowsForm namespace (on my example frmOne as System.Windows.Forms.Form)
By doing this, it will say UiPath that it needs to import System.Windows.Forms namespace when it will compile. The same manipulation is done when you want to import external (custom) namespace within UiPath
@Florent_Salendres
Florent, thanks a million. It worked perfectly. My main conceptual problem was that I didnāt realize the need to add the variable of type System.Windows.Forms.Form. And now thatās going to help me out tremendously in the future.
Very kind of you indeed!
(By the way, if you have any knowledge of incorporating AutoHotkey.Interop into UiPath Iād really love to hear about it. I was able to compile the package and add it as a Nuget package locally, and I can run scripts. But so far I havenāt been able to get variables or arguments in or out of the AHK scripts except by writing them as a file and then opening them in UiPath, which kind of defeats the purpose. )
Once again, thanks so much for this extremely useful and detailed walkthrough.
Regards,
burque505
Unfortunately, I do not have experience with AHK but the question is, by using AHK engine as it is done here in a .Net app, can you achieve getting your arguments In/Out between engine => .Net => engine?
If yes, I do not see any reason why having a Custom Activity written in .Net would not return or accept your arguments.
Can you share, in MP if you want to, your .cs class inside the custom activity, i could have a look on it later.
Thanks, Florent. Iāve been able to get a number of those examples
working in AHK by using the Telerik converter and translating the C# to VB.Net. Iām working now with Import statements, if I have any luck Iāll
post. I just tried this code below, which works in VB.NET from VS, in an
Invoke Code block and got a late binding error. Iāll see if I can use
reflection, maybe Iāll have better luck
I think it might be easier to achieve what you want creating your custom activity as shown on the doc bellow.
later you can import the created custom activity to the studio as follow.
There error you are encoutering come from the fact that you need to be explicit with the objects you are dealing with about their types.
You cannot declare AHK just as object on the Invoke code, you would need to specify its type as follow.
Dim AHK as new AutoHotKeyEngine (iām not sure this is the correct type). If the type comes from an external dll it would need to be imported to UiPath first.
@Florent_Salendres,
Thanks once again, I will try that. I have been trying to get an instance of AutoHotkeyEngine, not via a Custom Activity, but rather using something based on TDagsvikās workflow below. Iām including my feeble attempt so far as well, which is incomplete and doesnāt work.
regards,
burque505 Turn_ScrollLock_Off.xaml (12.7 KB) Ahk attempt.xaml (10.1 KB)
I will be sure to post the results of my efforts with a custom activity. I really appreciate you taking the time to help.
I am new to UIPath and tried your code. The main.xaml I download works but when I try the steps in my project it fails. the form does not show and breakpoint does not work either.
please help.