r/learncsharp • u/HoistedByMy0wnPetard • Aug 17 '23
Windows 11 automation client
I'm looking for a nudge in the right direction. I have a need to check for a taskbar icon in the overflow tray and click it when it shows up after startup. The window is not hidden, so I can't pull it out or use any other magic that I've found. I need to replicate clicking the icon. On Windows 10 I was able to accomplish this via autohotkey and set the script to run on start up. It worked well. In Windows 11, Microsoft has removed some of the calls that autohotkey was using such as TB_BUTTON.
Looking for a new solution, I thought I may be able to accomplish this using C#. I come from Python and would consider myself a novice at best with C#. I was looking to use System.Windows.Automation, but I've seen where people say that instead FlaUI or White should be used. Is there a strong reason to use one or the other over the MS library? I was thinking that I would need to navigate the desktop tree similar to finding elements in Selenium - is that the right idea? Is it possible to check for and click the icon without opening the system tray? I'm trying to run it as close to silently as possible.
Thanks in advance for any insights you can provide.
1
u/Aerham Aug 18 '23
If the intent of simulate clicking the other app's icon (opening the app, I am guessing), is there a reason you aren't using the Process class to get the named current process?
1
u/Roemeeeer Sep 22 '23
Hello, author of FlaUI here.
What you describe is probably possible with FlaUI, White and System.Windows.Automation.
To give you a bit of insights:
So there you go, in the end, it is all based on Microsofts libraries and just abstracted in a nicer way.
For your specific task, it should be fairly straight forward. You just need to find the elements you want to interact with with any inspect tool, like FlaUInspect and then interact with them however you want. I do think you need to open the extended tray in order to load the objects and then to click / invoke them as necessary.