You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am tired of having to make four clicks to open a specific meeting in Microsoft Teams, so I decided to make a script to do it with a custom key combination. Phind gave me a starting script using System.Windows.Automation:
Phind's script
openSystemopenSystem.Windows.Automation// Initialize the UI Automation frameworkletautomation=new UIAutomationClient.CUIAutomation()// Define a function to find a window by its titleletfindWindowByTitle title =
automation.GetRootElement().FindFirst(TreeScope.Descendants,
Automation.ControlTypeProperty.PropertyCondition(ControlType.Window),
Automation.NameProperty.PropertyCondition(title))// Define a function to click a button by its nameletclickButtonByName name =letbutton= automation.GetRootElement().FindFirst(TreeScope.Descendants,
Automation.ControlTypeProperty.PropertyCondition(ControlType.Button),
Automation.NameProperty.PropertyCondition(name))
button.InvokePattern.Invoke()// Define a function to move and maximize a windowletmoveAndMaximizeWindow(window:AutomationElement)=letwindowPattern= window.GetCurrentPattern(WindowPattern.Pattern):?> WindowPattern
windowPattern.SetWindowVisualState(WindowVisualState.Maximized)// Moving the window to a specific monitor would require calculating the screen position// This example does not cover moving the window// Main script logicletmain argv =// Attempt to find the Microsoft Teams windowletteamsWindow= findWindowByTitle "Microsoft Teams"if teamsWindow <>nullthen// Attempt to find and click the "Join Now" button
clickButtonByName "Join Now"// Move and maximize the window (example)
moveAndMaximizeWindow teamsWindow
else
printfn "Microsoft Teams window not found."
Current state
After a convoluted sequence of potential solutions tried, I arrived at a .NET project targeting net8.0-windows (in case these utilities are Windows-specific).
I have referenced the DLL directly from my .fsproj:
Now I can open System.Windows.Automation, which is more than I have been able to do using other means so far, but UIAutomationClient is still not defined, despite the DLL reference.
What am I missing?
dotnet/core#3283 suggests that I need to be writing a .NET desktop application, but I specifically wish to avoid clicks, not to open more GUI windows, so I would prefer to use a console application if at all possible.
The text was updated successfully, but these errors were encountered:
Context
I am tired of having to make four clicks to open a specific meeting in Microsoft Teams, so I decided to make a script to do it with a custom key combination. Phind gave me a starting script using
System.Windows.Automation
:Phind's script
Current state
After a convoluted sequence of potential solutions tried, I arrived at a .NET project targeting
net8.0-windows
(in case these utilities are Windows-specific).I have referenced the DLL directly from my .fsproj:
Now I can open
System.Windows.Automation
, which is more than I have been able to do using other means so far, butUIAutomationClient
is still not defined, despite the DLL reference.What am I missing?
dotnet/core#3283 suggests that I need to be writing a .NET desktop application, but I specifically wish to avoid clicks, not to open more GUI windows, so I would prefer to use a console application if at all possible.
The text was updated successfully, but these errors were encountered: