Skip to content

Commit

Permalink
Rename the project to more generic "AB Menu"
Browse files Browse the repository at this point in the history
  • Loading branch information
CrendKing committed Mar 21, 2022
1 parent f757c63 commit bd8fc32
Show file tree
Hide file tree
Showing 33 changed files with 393 additions and 330 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,5 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd

release*.bat
release.cmd
*.zip
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
# Compare Menu
# AB Menu

A Windows context menu shell extension that proxies general comparison commands to any diff application.
A Windows context menu shell extension that proxies user configured commands accepting exactly two launch arguments (thus "AB" in the name) to any application.

While many popular comparison applications such as Beyond Compare come with their own such shell extensions help improve user experience, there are good ones that still do not have. Rather than requesting each developer team to come up with their own solution, why not build a general one that can work everywhere as long as their take standard input arguments?
Among the examples of such applications are comparison tools, file copy tools and text editors for side-by-side editing.

The concept of such context menu is simple:
If the application does not come with its own shell extension, instead of having to manually type in terminal or create shortcut of it, user of this shell extension can create template of launch command with the two argument placeholders, select the item(s) in Windows Explorer and launch.

* When exactly two files or two directories are selected, a "Compare Two" command becomes available, sending the two paths to the configured diff application.
* If only one object is selected for the first time, the menu remembers its path.
* If another object is selected afterwards, the menu either sends both paths to the diff application and reset, or replaces the previously remembered path, depending on user choice.
There are multiple ways to select items:

Note that a file can't be compared to a directory. So if the types mismatch, "Compare Two" won't be available, and the only option for single select mode is replacement.
* When exactly two items (both files or both folders but not mixed) are selected, the shell extension will display the value of each argument placeholder and launch app.
* When only one item is selected for the first time, the shell extension remembers its path.
* When a different object is selected afterwards, the shell extension either launch app with the two arguments, or replaces the previously remembered first item, depending on user choice.

Again, the two items must be both files or both folders but not mixed.

## Install

* Unpack the archive.
* Run install.bat to register the shell extension.
* Open config.reg and edit the application path. `\` in the path needs to be escaped as `\\`.
* The command line part should include both the full path to the comparer executable, and its arguments with `%LEFT%` and `%RIGHT%` placeholders.
* In the config.reg, we provided an example command line for [010 Editor's `-compare` parameter](https://www.sweetscape.com/010editor/manual/CommandLine.htm#-compare).
* config.reg has some examples of user configurable commands. You can edit it and import into registry. The first selected item replaces the `%FIRST%` placeholder, while the second one replaces `%SECOND%`. `\` in the path needs to be escaped as `\\`.

## Uninstall

* Run uninstall.bat to de-register the shell extension.
* Open Registry Editor and remove `HKEY_CURRENT_USER\Software\AB Menu`.

## Build

A build script `build.ps1` is included to automate the process. It obtains dependencies and starts compilation. Before running `build.ps1`, make sure you have the latest Visual Studio installed. The script will automatically assume the Visual Studio developer environment and check out dependencies. To run the script, pass the target configuration and platform as arguments, e.g. `build.ps1 Debug x64` or `build.ps1 Release x86`.

## Screenshots

Compare Two
![Compare Two](screenshots/compare_two.webp)
When two items are selected:

![Two selected](screenshots/two_selected.webp)

When the first item is selected:

Select First
![Select First](screenshots/select_first.webp)

Select Second
After the first item is confirmed, when the second item is selected:

![Select Second](screenshots/select_second.webp)
2 changes: 1 addition & 1 deletion compare_menu.sln → ab_menu.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{4E19C66E-E508-4D7A-876B-6B1D945B7F54}") = "compare_menu", "compare_menu.vcxproj", "{57F63F56-0E76-492D-B6F6-AE1D306D4057}"
Project("{4E19C66E-E508-4D7A-876B-6B1D945B7F54}") = "ab_menu", "ab_menu.vcxproj", "{57F63F56-0E76-492D-B6F6-AE1D306D4057}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
15 changes: 7 additions & 8 deletions compare_menu.vcxproj → ab_menu.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,33 @@
<ItemGroup>
<ClCompile Include="src\default.cpp" />
<ClCompile Include="src\environment.cpp" />
<ClCompile Include="src\comparer_cmd.cpp" />
<ClCompile Include="src\item.cpp" />
<ClCompile Include="src\module.cpp" />
<ClCompile Include="src\menu.cpp" />
<ClCompile Include="src\pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="src\terminal_cmd.cpp" />
<ClCompile Include="src\commands.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\default.h" />
<ClInclude Include="src\environment.h" />
<ClInclude Include="src\comparer_cmd.h" />
<ClInclude Include="src\item.h" />
<ClInclude Include="src\menu.h" />
<ClInclude Include="src\min_windows.h" />
<ClInclude Include="src\pch.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\terminal_cmd.h" />
<ClInclude Include="src\commands.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="src\compare_menu.rc" />
<ResourceCompile Include="src\ab_menu.rc" />
</ItemGroup>
<ItemGroup>
<None Include="src\$(ProjectName).def" />
<None Include="src\compare_menu.rgs" />
<None Include="src\ab_menu.rgs" />
</ItemGroup>
<ItemGroup>
<Image Include="src\compare.ico" />
<Image Include="src\ab.ico" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{57F63F56-0E76-492D-B6F6-AE1D306D4057}</ProjectGuid>
Expand Down Expand Up @@ -118,4 +117,4 @@
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
</Project>
17 changes: 7 additions & 10 deletions compare_menu.vcxproj.filters → ab_menu.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ClCompile Include="src\module.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\terminal_cmd.cpp">
<ClCompile Include="src\commands.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\environment.cpp">
Expand All @@ -33,9 +33,6 @@
<ClCompile Include="src\item.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\comparer_cmd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\default.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -50,7 +47,7 @@
<ClInclude Include="src\menu.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\terminal_cmd.h">
<ClInclude Include="src\commands.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\environment.h">
Expand All @@ -59,28 +56,28 @@
<ClInclude Include="src\item.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\comparer_cmd.h">
<ClInclude Include="src\default.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\default.h">
<ClInclude Include="src\min_windows.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="src\compare_menu.rc">
<ResourceCompile Include="src\ab_menu.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="src\compare_menu.rgs">
<None Include="src\ab_menu.rgs">
<Filter>Resource Files</Filter>
</None>
<None Include="src\$(ProjectName).def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Image Include="src\compare.ico">
<Image Include="src\ab.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Set-Location $PSScriptRoot
$configuration = $args[0]
$platform = $args[1]

MSBuild.exe -property:"Configuration=${configuration};Platform=${platform}" -maxCpuCount -nologo compare_menu.sln
MSBuild.exe -property:"Configuration=${configuration};Platform=${platform}" -maxCpuCount -nologo ab_menu.sln
exit $LASTEXITCODE
Binary file modified config.reg
Binary file not shown.
4 changes: 2 additions & 2 deletions install.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
regsvr32 "%~dp0acompare_menu_64.dll"
regsvr32 "%~dp0acompare_menu_32.dll"
regsvr32 "%~dp0ab_menu_64.dll"
regsvr32 "%~dp0ab_menu_32.dll"
10 changes: 0 additions & 10 deletions release.cmd

This file was deleted.

Binary file removed screenshots/compare_two.webp
Binary file not shown.
Binary file modified screenshots/select_first.webp
Binary file not shown.
Binary file modified screenshots/select_second.webp
Binary file not shown.
Binary file added screenshots/two_selected.webp
Binary file not shown.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/compare_menu.rc → src/ab_menu.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ END
// REGISTRY
//

IDS_COMPARE_MENU REGISTRY "compare_menu.rgs"
IDS_AB_MENU REGISTRY "ab_menu.rgs"


/////////////////////////////////////////////////////////////////////////////
Expand All @@ -60,7 +60,7 @@ IDS_COMPARE_MENU REGISTRY "compare_menu.rgs"

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "src\compare.ico"
IDI_ICON ICON "src\\ab.ico"

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/compare_menu.rgs → src/ab_menu.rgs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
HKEY_CLASSES_ROOT {
NoRemove CLSID {
ForceRemove {59D49316-D3FD-425B-A175-41DEB301AB1F} = s 'Compare Menu Shell Extension' {
ForceRemove {59D49316-D3FD-425B-A175-41DEB301AB1F} = s 'AB Menu Shell Extension' {
InprocServer32 = s '%MODULE%' {
val ThreadingModel = s 'Apartment'
}
Expand All @@ -9,7 +9,7 @@ HKEY_CLASSES_ROOT {

NoRemove AllFilesystemObjects {
NoRemove shell {
CompareMenu {
ABMenu {
val ExplorerCommandHandler = s '{59D49316-D3FD-425B-A175-41DEB301AB1F}'
}
}
Expand Down
Loading

0 comments on commit bd8fc32

Please sign in to comment.