Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/GitHub actions #27

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
22 changes: 22 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
 on:
push:
branches:
- master
tags:
- '*'
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- run: |
dotnet restore
dotnet build
working-directory: src
- uses: actions/upload-artifact@v3
with:
name: build-artifact
path: src/FlaUInspect/bin
14 changes: 14 additions & 0 deletions .github/workflows/pr-validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
 on:
pull_request:
jobs:
pr-validate:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- run: |
dotnet restore
dotnet build
working-directory: src
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# FlaUInspect
![FlaUInspect](/FlaUInspect.png?raw=true)
### Build
| What | Info / Link |
| ---- | ----- |
| *Build* | [![Build status](https://ci.appveyor.com/api/projects/status/q2poa5bpenso8eyv?svg=true)](https://ci.appveyor.com/project/RomanBaeriswyl/flauinspect) |
| *FlaUInspect* | [![FlaUInspect](https://img.shields.io/badge/FlaUInspect-choco-brightgreen.svg)](https://chocolatey.org/packages/flauinspect)<br />`choco install flauinspect` |
| *CI Artefacts* | [FlauInspect CI](https://ci.appveyor.com/project/RomanBaeriswyl/flauinspect/build/artifacts) |
| What | Info / Link |
|----------------| ----- |
| *Build* | [![Build status](https://ci.appveyor.com/api/projects/status/q2poa5bpenso8eyv?svg=true)](https://ci.appveyor.com/project/RomanBaeriswyl/flauinspect) |
| *FlaUInspect* | [![FlaUInspect](https://img.shields.io/badge/FlaUInspect-choco-brightgreen.svg)](https://chocolatey.org/packages/flauinspect)<br />`choco install flauinspect` |
| *CI Artifacts* | [FlauInspect CI](https://ci.appveyor.com/project/RomanBaeriswyl/flauinspect/build/artifacts) |

### Installation
To install FlaUInspect, either build it yourself, get it from chocolatey (https://community.chocolatey.org/packages/flauinspect) or get the zip from the releases page here on GitHub.
Expand Down
2 changes: 1 addition & 1 deletion src/FlaUInspect/App.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down
13 changes: 11 additions & 2 deletions src/FlaUInspect/Core/HoverMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using FlaUI.Core;
using FlaUI.Core.AutomationElements;
using FlaUI.Core.Input;
using System.Runtime.InteropServices;
using FlaUInspect.ViewModels;

namespace FlaUInspect.Core
{
Expand All @@ -13,15 +15,17 @@ public class HoverMode
private readonly AutomationBase _automation;
private readonly DispatcherTimer _dispatcherTimer;
private AutomationElement _currentHoveredElement;
private MainViewModel _mv;

public event Action<AutomationElement> ElementHovered;

public HoverMode(AutomationBase automation)
public HoverMode(AutomationBase automation, MainViewModel mv)
{
_automation = automation;
_dispatcherTimer = new DispatcherTimer();
_dispatcherTimer.Tick += DispatcherTimerTick;
_dispatcherTimer.Interval = TimeSpan.FromMilliseconds(500);
_mv = mv;
}

public void Start()
Expand All @@ -38,7 +42,7 @@ public void Stop()

private void DispatcherTimerTick(object sender, EventArgs e)
{
if (System.Windows.Input.Keyboard.Modifiers.HasFlag(System.Windows.Input.ModifierKeys.Control))
if (System.Windows.Input.Keyboard.Modifiers.HasFlag(System.Windows.Input.ModifierKeys.Control) && System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.LWin))
{
var screenPos = Mouse.Position;
try
Expand Down Expand Up @@ -70,6 +74,11 @@ private void DispatcherTimerTick(object sender, EventArgs e)
{
Console.WriteLine($"Exception: {ex.Message}");
}
catch (COMException cex)
{
_mv.ComExceptionDetected = true;
//MessageBox.Show(cex.Message, "DispatcherTimeTick caught COM exception. Please refresh inspector", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
}
}
Expand Down
39 changes: 35 additions & 4 deletions src/FlaUInspect/FlaUInspect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,29 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FlaUInspect</RootNamespace>
<AssemblyName>FlaUInspect</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -27,7 +42,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>true</Prefer32Bit>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -44,6 +59,7 @@
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
Expand Down Expand Up @@ -176,13 +192,28 @@
<Resource Include="Resources\Calendar.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FlaUI.Core">
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="FlaUI.UIA2">
<Version>3.2.0</Version>
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="FlaUI.UIA3">
<Version>3.2.0</Version>
<Version>4.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion src/FlaUInspect/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/FlaUInspect/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions src/FlaUInspect/ViewModels/DetailViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using FlaUI.Core;
using FlaUInspect.Core;
using System;
using System.Threading.Tasks;

namespace FlaUInspect.ViewModels
{
Expand All @@ -8,23 +10,36 @@ public interface IDetailViewModel
string Key { get; set; }
string Value { get; set; }
bool Important { get; set; }
bool HasExecutableAction { get; set; }
Action ActionToExecute { get; set; }
}

public class DetailViewModel : ObservableObject, IDetailViewModel
{
public DetailViewModel(string key, string value)
public DetailViewModel(string key, string value, Action actionToExecute = null)
{
Key = key;
Value = value;
if (actionToExecute != null)
{
HasExecutableAction = true;
}
else
{
HasExecutableAction = false;
}
ActionToExecute = actionToExecute;
}

public string Key { get { return GetProperty<string>(); } set { SetProperty(value); } }
public string Value { get { return GetProperty<string>(); } set { SetProperty(value); } }
public bool Important { get { return GetProperty<bool>(); } set { SetProperty(value); } }
public bool HasExecutableAction { get { return GetProperty<bool>(); } set { SetProperty(value); } }
public Action ActionToExecute { get; set; }

public static DetailViewModel FromAutomationProperty<T>(string key, IAutomationProperty<T> value)
{
return new DetailViewModel(key, value.ToDisplayText());
return new DetailViewModel(key, value.ToDisplayText(), null);
}
}
}
}
24 changes: 23 additions & 1 deletion src/FlaUInspect/ViewModels/ElementViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,17 @@ private List<DetailGroupViewModel> LoadDetails()
}

// Pattern details
var allSupportedPatterns = AutomationElement.GetSupportedPatterns();
//It is here, at GetSupportedPatterns, it crashes if the selected element in inspector, is no longer present.
PatternId[] allSupportedPatterns = new PatternId[0];
try
{
allSupportedPatterns = AutomationElement.GetSupportedPatterns();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Caught '{ex.GetType()}': {ex.Message}");
//Handling exception. Details will show something is wrong. Would be great to show the red menu line aswell.
}
var allPatterns = AutomationElement.Automation.PatternLibrary.AllForCurrentFramework;
var patterns = new List<DetailViewModel>();
foreach (var pattern in allPatterns)
Expand Down Expand Up @@ -364,6 +374,18 @@ private List<DetailGroupViewModel> LoadDetails()
};
detailGroups.Add(new DetailGroupViewModel("Toggle Pattern", patternDetails));
}

//InvokePattern
if (allSupportedPatterns.Contains(AutomationElement.Automation.PatternLibrary.InvokePattern))
{
var pattern = AutomationElement.Patterns.Invoke.Pattern;
var patternDetails = new List<DetailViewModel>
{
new DetailViewModel("Invokable", "Invoke", AutomationElement.Patterns.Invoke.Pattern.Invoke)
};
detailGroups.Add(new DetailGroupViewModel("Invoke Pattern", patternDetails));
}

// ValuePattern
if (allSupportedPatterns.Contains(AutomationElement.Automation.PatternLibrary.ValuePattern))
{
Expand Down
Loading