ddeltasolutions / UIDeskAutomation

This is a .NET library that can be used to automate Windows desktop programs based on their user interface. It is created on top of managed Microsoft UI Automation API.
2 stars 1 forks source link

How to fix a tricky issue? #5

Closed zydjohnHotmail closed 2 years ago

zydjohnHotmail commented 2 years ago

Hello, I have tried to write a program to upload some pictures to my facebook account. And I found some tricky issue. You can upload photos/videos to your facebook account, from home page, click on photos/videos icon within the "What's on your mind, User Name? Photo/video" group. The following code works for the first 4 files (photos or videos) Console.WriteLine("Click on What's on your mind, … ? Photo/video"); UIDA_Label mind_video = engine.GetDesktopPane().Pane("Facebook - Google Chrome").Document("Facebook") .GroupAt("", 2).Group("Create a post").Button("Photo/video").Label("Photo/video"); mind_video.Highlight(); mind_video.Click(); engine.Sleep(1500);

However, from the 5th files, the above code stops working. As I can see from the Spy tools, the UIDA_Label mind_video seems to change to another value, like: engine.GetDesktopPane().Pane("Facebook - Google Chrome").Document("Facebook") .GroupAt("", 3).Group("Create a post").Button("Photo/video").Label("Photo/video");

However, the label position remain the same. Is it possible to always click on the same position, no matter what the engine consider the underlying label should be? Thanks,

ddeltasolutions commented 2 years ago

Hi, Instead of engine.GetDesktopPane().Pane("Facebook - Google Chrome").Document("Facebook") .GroupAt("", 2).Group("Create a post").Button("Photo/video").Label("Photo/video"); or engine.GetDesktopPane().Pane("Facebook - Google Chrome").Document("Facebook") .GroupAt("", 3).Group("Create a post").Button("Photo/video").Label("Photo/video");

use this: UIDA_Label mind_video = engine.GetDesktopPane().Pane("Facebook - Google Chrome").Document("Facebook").Label("Photo/video", true);

This way the library will look in all descendants of "Facebook" document for the "Photo/video" label not only in the immediate children.

Best regards.

În vin., 11 mar. 2022 la 12:17, zydjohnHotmail @.***> a scris:

Hello, I have tried to write a program to upload some pictures to my facebook account. And I found some tricky issue. You can upload photos/videos to your facebook account, from home page, click on photos/videos icon within the "What's on your mind, User Name? Photo/video" group. The following code works for the first 4 files (photos or videos) Console.WriteLine("Click on What's on your mind, … ? Photo/video"); UIDA_Label mind_video = engine.GetDesktopPane().Pane("Facebook - Google Chrome").Document("Facebook") .GroupAt("", 2).Group("Create a post").Button("Photo/video").Label("Photo/video"); mind_video.Highlight(); mind_video.Click(); engine.Sleep(1500);

However, from the 5th files, the above code stops working. As I can see from the Spy tools, the UIDA_Label mind_video seems to change to another value, like: engine.GetDesktopPane().Pane("Facebook - Google Chrome").Document("Facebook") .GroupAt("", 3).Group("Create a post").Button("Photo/video").Label("Photo/video");

Message ID: @.***>

zydjohnHotmail commented 2 years ago

It is working now. Thanks,

ddeltasolutions commented 2 years ago

You're welcome.

În vin., 11 mar. 2022 la 17:47, zydjohnHotmail @.***> a scris:

It is working now. Thanks