I have a requirement where i have a Windows form (which i'm using for Login). I have two buttons Submit and Cancel.
Once the robot activity starts, form is activated. I'm using a Wait for event for the Submit button click. Once user enters userid and password, and on click on Submit - Login form will close and another automation will run.
If user clicks on Cancel button on the form, Login form will close.
Due to Wait for event is enabled for Submit button, on click on Cancel button, form is closing and it is not activating again. I have tried using Hide also. If i have enabled wait for event for Cancel button once login form is activated, it is working as expected.
Here i need to take care of both scenarios, need to implement Wait for event for both the buttons, based on click on the button in the form , the automation should run. Kindly help me.
I am not really understanding what you are trying to do. If you are creating your own windows form, there is no need to wait for any events. You would simply respond to the click events from the buttons to trigger whatever logic you needed. You are correct to call Hide instead of Close, although I don't really think it matters as Close doesn't really Close (or that would terminate the application). Perhaps you can share your solution or at least screenshots of the automations and I can provide a better suggestion.
Please find the attached screenshot of my current code (masked some info).
On click on Submit, another automation will start (AutoPRIME), and if it is success, we are returning some values to PEGA using SetCompletionStatus and GetCompletionStatus methods. If I dont use Wait For Event on Submit button, On click on Submit button automation is starting and working well, but while returning the values, It is throwing an error, "No activity is in progress" because there is no connector from Login form to Submit button.
Instead of using the Click event to trigger the AutoPrime automation, you should come off of the WaitForEvent fired execution path. That should keep the activity thread intact. Off of the timeout, you can hide your form and complete the activity (or do something else like prompt the user to wait longer or whatever to preserve that thread).