2012-01-06 58 views
3

我試圖自動化流利的功能區控件(www.fluent.codeplex.com)。我成功地將大部分控件自動化。但有一個問題,如關閉,最大化和最小化按鈕不被UI自動化工具識別或識別,例如使用Visual Studio的編碼UI測試。間諜工具不識別關閉,最大化,最小化等按鈕。我無法通過自動化關閉應用程序(使用流暢的功能區)。在Fluent(Codeplex)功能區中自動關閉,最大化和最小化功能區 - WPF應用程序

我在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> 

看着下面的代碼段我試過很多的東西(像把自動化標識),但沒有奏效。我在看代碼的錯誤部分?

有人可以幫助把自動化用戶界面或名稱放在關閉按鈕或通過爲什麼我可以解決問題的一些變化?唯一的要求是應用程序的「關閉」,「最大化」,「最小化」按鈕應通過UI自動化工具進行識別。

問候

+0

任何解決方案?我已將此報告給Codeplex,但尚未回覆。 – user1134352 2012-01-06 20:06:54

回答

0

這不會幫助您識別按鍵,但你可以嘗試發送標準的鍵盤快捷方式窗口實際執行的操作:

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

我可以像關閉應用程序一樣:文件 - >退出。但是我的要求是通過自動化工具和一些自動化UID或名稱來識別功能區窗口的關閉,最大化和最小化按鈕。所以,點擊關閉按鈕應該可以通過像Visual Studio這樣的自動化工具來工作。 – user1134352 2012-01-07 08:08:48

0

您可以嘗試Automation Spy了第二次檢查。如果UI自動化沒有給你任何東西,你可以嘗試發送(參見SendMessage)Win32消息,如WM_CLOSE到控制窗口,並且可以使用參數SW_MAXIMIZE,SW_MINIMIZE的ShowWindow函數。