Fluent(Codeplex) Ribbon 中关闭、最大化、最小化按钮的自动化 - WPF 应用程序

发布于 2024-12-25 19:08:01 字数 2581 浏览 4 评论 0原文

我正在尝试自动化流畅的功能区控件(www. Fluent.codeplex.com)。我成功地实现了大部分控制的自动化。但存在一个问题,例如“使用 Visual Studio 进行编码的 UI 测试”等 UI 自动化工具无法识别或识别“关闭”、“最大化”和“最小化”按钮。 Spy 工具无法识别关闭、最大化、最小化等按钮。我无法通过自动化关闭应用程序(使用流畅的功能区)。

我正在查看 RibbonWindow.xaml 中的以下代码部分,

<StackPanel x:Name="PART_ButtonsPanel" HorizontalAlignment="Right" Margin="0,8,8,0" VerticalAlignment="Top" Orientation="Horizontal">
          <Button x:Name="minimizeButton" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19" BorderThickness="1,0,0,1" Command="{x:Static Fluent:RibbonWindow.MinimizeCommand}">
            <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="{DynamicResource ImageCaptionButtonMinimize}" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
          </Button>
          <Button x:Name="maximizeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19" BorderThickness="0,0,0,1" Command="{x:Static Fluent:RibbonWindow.MaximizeCommand}">
            <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="{DynamicResource ImageCaptionButtonMaximize}" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
          </Button>
          <Button x:Name="normalizeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19" BorderThickness="0,0,0,1" Command="{x:Static Fluent:RibbonWindow.NormalizeCommand}">
            <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="{DynamicResource ImageCaptionButtonNormalize}" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
          </Button>
          <Button x:Name="closeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19" BorderThickness="0,0,1,1" Background="Red" Command="{x:Static Fluent:RibbonWindow.CloseCommand}">
            <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="{DynamicResource ImageCaptionButtonClose}" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
          </Button>
        </StackPanel>

我尝试了很多东西(例如放置自动化 Id),但没有任何效果。我是否看到了错误的代码部分?

有人可以帮助将自动化 UI 或名称放入“关闭”按钮中,或者进行一些更改来说明为什么我可以解决问题吗?唯一的要求是应用程序的关闭、最大化、最小化按钮应由 UI 自动化工具识别。

问候

I am trying to Automate the fluent Ribbon Controls (www.fluent.codeplex.com). I am successful in automating most of the controls. But there is an issue like Close, Maximize and Minimize Buttons are not recognized or identified by UI Automation Tool, for example, Coded UI Test using Visual Studio. The Spy tool doesn't identify close, maximize, minimize, etc button. I am not able to close the application (which uses fluent Ribbon) through Automation.

I was looking at the following section of code in RibbonWindow.xaml

<StackPanel x:Name="PART_ButtonsPanel" HorizontalAlignment="Right" Margin="0,8,8,0" VerticalAlignment="Top" Orientation="Horizontal">
          <Button x:Name="minimizeButton" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19" BorderThickness="1,0,0,1" Command="{x:Static Fluent:RibbonWindow.MinimizeCommand}">
            <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="{DynamicResource ImageCaptionButtonMinimize}" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
          </Button>
          <Button x:Name="maximizeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19" BorderThickness="0,0,0,1" Command="{x:Static Fluent:RibbonWindow.MaximizeCommand}">
            <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="{DynamicResource ImageCaptionButtonMaximize}" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
          </Button>
          <Button x:Name="normalizeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19" BorderThickness="0,0,0,1" Command="{x:Static Fluent:RibbonWindow.NormalizeCommand}">
            <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="{DynamicResource ImageCaptionButtonNormalize}" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
          </Button>
          <Button x:Name="closeButton" Margin="-1,0,0,0" Style="{DynamicResource CaptionButtonStyle}" Width="35" Height="19" BorderThickness="0,0,1,1" Background="Red" Command="{x:Static Fluent:RibbonWindow.CloseCommand}">
            <Image Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="{DynamicResource ImageCaptionButtonClose}" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
          </Button>
        </StackPanel>

I tried lots of stuff (like putting Automation Id) but none worked. Am I looking at wrong portion of code?

Can somebody help in putting Automation UI or Name in the Close Button or some changes through why I can solve the problem? The only requirement is Close, Maximize, Minimize button of the application should be identified by UI Automation tool.

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

So要识趣 2025-01-01 19:08:01

这不会帮助您识别按钮,但您可以尝试将标准键盘快捷键发送到窗口以实际执行操作:

//close the window
Keyboard.SendKeys(myWindow, "{F4}", ModifierKeys.Alt);

This won't help you identify the buttons, but you could try sending the standard keyboard shortcuts to the window to actually perform the actions:

//close the window
Keyboard.SendKeys(myWindow, "{F4}", ModifierKeys.Alt);
孤独难免 2025-01-01 19:08:01

您可以尝试使用 Automation Spy 进行第二次检查。如果 UI 自动化没有为您提供任何内容,您可以尝试发送(请参阅 SendMessage) Win32 消息,例如WM_CLOSE 到控制窗口,您可以使用 ShowWindow 函数,带有参数 SW_MAXIMIZE、SW_MINIMIZE。

You can try Automation Spy for a second check. If UI Automation doesn't give you anything you can try sending (see SendMessage) Win32 messages like WM_CLOSE to the control window and you can use ShowWindow function with parameter SW_MAXIMIZE, SW_MINIMIZE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文