Question
Shuurgan
CN
Last activity: 4 Dec 2024 21:31 EST
There is a button that cannot be used no matter how it is set.
Hello, I have a key that I cannot use no matter what method I use. The key can be sensed but cannot be clicked. In version 19.1, it can be used through the sendkeys method, but in the pega robot 22.1 version of win11, it cannot be used through sendkeys. The function is set and it can be detected and executed but it cannot be clicked. Is there any special method that can be used? BAO
-
Reply
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 3 Dec 2024 21:24 EST
Pegasystems Inc.
US
@BAOX17175074 Not exactly. A thread is essentially a line of execution. Certain things block a thread. For example, if you had the following C# code;
public string showDialog()
{
string temp = "Hi";
MessageBox.Show(temp);
return temp;
}
When you call this method, you won't be able to execute any steps after it until the message dialog had been dismissed, because it blocks the thread. This is a simpler version of what happens when automation methods trigger modal dialogs. Not all methods are synchronous (meaning they occur on one thread), nor do all apps use the same thread to display dialogs, but it is common enough that you can see examples (like the one you've encountered). What you would notice if you examined the logs would be that your log messages around the automation steps would stop once the dialog was present and would not resume until it was dismissed. This is just something you may need to watch out for.
Pegasystems Inc.
US
@BAOX17175074Just to clarify, SendKeys worked in 19.1 and Windows 10, but in 22.1 and Windows 11, it does not work. Is this correct? I can say I have not seen a difference in SendKeys between Win 10 and Win 11, but I suppose that could be the issue. Is the control you are trying to click one that opens a file upload dialog? Is it similar to this one?
https://www.w3schools.com/howto/howto_html_file_upload_button.asp
If so, SendKeys('~') is working for me on Windows 11. I believe these controls can only be triggered with SendKeys because of browser security. You will need to handle the dialog on a separate thread though as the dialog is modal. This means SendKeys won't return until the dialog is dismissed. You would use a Parallel Process to use SendKeys on one thread and then on the second thread, wait for the dialog, populate it, and then close it.
I noticed in your screenshot you have adjusted the match rules. You might possibly be attached to the wrong control. Make sure you are attached to the input type="file" control.
Shuurgan
CN
@ThomasSasnett Thank you, Thomas. This problem has been solved perfectly in 22.1, the parallel process approach is great. BAO
Pegasystems Inc.
US
@BAOX17175074 You're welcome. The idea behind the parallel process is if you were looking at the runtime log while the dialog was launching, you would see the call to the SendKeys method, however the next automation step would never execute. This tells us that the method is being blocked from returning. This is usually the case when dealing with any dialogs that are modal to the application. The trick then is to call the method to launch the dialog on one thread while a second handles the dialog and ultimately dismisses it.
Shuurgan
CN
@ThomasSasnett In other words, the parallel process method is to let a certain module know more clearly what kind of processing it needs to do without being affected by the next or previous control. Is this what you mean? BAO
Accepted Solution
Updated: 3 Dec 2024 21:24 EST
Pegasystems Inc.
US
@BAOX17175074 Not exactly. A thread is essentially a line of execution. Certain things block a thread. For example, if you had the following C# code;
public string showDialog()
{
string temp = "Hi";
MessageBox.Show(temp);
return temp;
}
When you call this method, you won't be able to execute any steps after it until the message dialog had been dismissed, because it blocks the thread. This is a simpler version of what happens when automation methods trigger modal dialogs. Not all methods are synchronous (meaning they occur on one thread), nor do all apps use the same thread to display dialogs, but it is common enough that you can see examples (like the one you've encountered). What you would notice if you examined the logs would be that your log messages around the automation steps would stop once the dialog was present and would not resume until it was dismissed. This is just something you may need to watch out for.
Shuurgan
CN
@ThomasSasnett I see, thank you for your answer. BAO
Shuurgan
CN
@ThomasSasnett Hello,Thomas.When solving a problem, I can click the button correctly the first time I use parallel processing. However, I cannot click the button correctly the second time or in subsequent test projects. What is going on? BAO
Pegasystems Inc.
US
@BAOX17175074 I can't really tell you without more information. Are you certain the control is matched the second time around?
Pegasystems Inc.
US
@BAOX17175074I noticed that you do not have the bottom execution block from your Parallel Process connected in your screenshot. You should use that after you have dismissed the dialog to continue your automation. That isn't the cause of your issue likely, but I thought it was a good place to point out. That is the thread that will continue the execution of your main thread after both of your parallel threads have completed.
Thread Main: Calls Parallel Process
Thread One: SendKeys to open dialog
Thread Two: Waits for the dialog, handles dialog, closes dialog
Thread Main (bottom link): Next execution step in your process and ultimately on to the exit point.