Skip to content

Commit 839f7bd

Browse files
committed
v3.9
1 parent ef4e988 commit 839f7bd

File tree

12 files changed

+469
-343
lines changed

12 files changed

+469
-343
lines changed

Changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
### v3.9
3+
4+
- GUI redesign
5+
- Relative paths
6+
- Regex filters
7+
- Fix 'Show only when Ctrl key is pressed'
8+
- Tab order fix

License.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
MIT License
33

4-
Copyright (C) 2008-2020 Frank Skare (stax76)
4+
Copyright (C) 2008-2021 Frank Skare (stax76)
55

66
Permission is hereby granted, free of charge, to any person
77
obtaining a copy of this software and ssociated documentation

OpenWithPPGUI/MainForm.resx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,6 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120-
<metadata name="tsMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121-
<value>81, 40</value>
122-
</metadata>
123-
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
124-
<data name="ddbHelp.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
125-
<value>
126-
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
127-
YQUAAAAJcEhZcwAALEoAACxKAXd6dE0AAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
128-
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
129-
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
130-
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
131-
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
132-
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
133-
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
134-
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
135-
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
136-
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
137-
</value>
138-
</data>
139120
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
140121
<value>142</value>
141122
</metadata>

OpenWithPPGUI/MainForm.vb

Lines changed: 320 additions & 250 deletions
Large diffs are not rendered by default.

OpenWithPPGUI/Misc.vb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ Public Class Item
108108
Public Directories As Boolean
109109
Public FileTypes As String = ""
110110
Public FileTypesDisplay As String = ""
111-
Public HideWindow As Boolean
111+
Public Filter As String = ""
112112
Public Hidden As Boolean
113+
Public HideWindow As Boolean
113114
Public IconFile As String = ""
114115
Public IconIndex As Integer
115116
Public Name As String = ""
@@ -118,7 +119,7 @@ Public Class Item
118119
Public SubMenu As Boolean = True
119120
Public WorkingDirectory As String = ""
120121

121-
Public Function CompareTo(obj As Object) As Integer Implements System.IComparable.CompareTo
122+
Function CompareTo(obj As Object) As Integer Implements System.IComparable.CompareTo
122123
Return Name.CompareTo(DirectCast(obj, Item).Name)
123124
End Function
124125
End Class

OpenWithPPGUI/My Project/AssemblyInfo.vb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Imports System.Runtime.InteropServices
88
' Review the values of the assembly attributes
99

1010
<Assembly: AssemblyTitle("Open with++")>
11-
<Assembly: AssemblyDescription("Shell extension allowing to customize File Explorer context menu")>
11+
<Assembly: AssemblyDescription("A shell extension that allows customizing the File Explorer context menu.")>
1212
<Assembly: AssemblyCompany("Frank Skare (stax76)")>
1313
<Assembly: AssemblyProduct("Open with++")>
14-
<Assembly: AssemblyCopyright("Copyright (C) 2008-2020 Frank Skare (stax76)")>
14+
<Assembly: AssemblyCopyright("Copyright (C) 2008-2021 Frank Skare (stax76)")>
1515
<Assembly: AssemblyTrademark("")>
1616

1717
<Assembly: ComVisible(False)>
@@ -29,5 +29,5 @@ Imports System.Runtime.InteropServices
2929
' You can specify all the values or you can default the Build and Revision Numbers
3030
' by using the '*' as shown below:
3131

32-
<Assembly: AssemblyVersion("3.8.0.0")>
33-
<Assembly: AssemblyFileVersion("3.8.0.0")>
32+
<Assembly: AssemblyVersion("3.9.0.0")>
33+
<Assembly: AssemblyFileVersion("3.9.0.0")>

OpenWithPPGUI/OpenWithPPGUI.vbproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@
162162
</EmbeddedResource>
163163
</ItemGroup>
164164
<ItemGroup>
165+
<None Include="..\Changelog.md">
166+
<Link>Changelog.md</Link>
167+
</None>
168+
<None Include="..\README.md">
169+
<Link>README.md</Link>
170+
</None>
165171
<None Include="app.config">
166172
<SubType>Designer</SubType>
167173
</None>

OpenWithPPGUI/OptionsForm.Designer.vb

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenWithPPShellExtension/Main.cpp

Lines changed: 77 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "stdafx.h"
33
#include "Main.h"
44

5+
#include <regex>
6+
#include <filesystem>
57

68
Item::~Item()
79
{
@@ -13,6 +15,40 @@ Item::~Item()
1315
}
1416

1517

18+
std::wstring JoinList(std::list<std::wstring>* list, const std::wstring& sep)
19+
{
20+
std::wstring ret;
21+
22+
if ((*list).size() > 0)
23+
ret = *(*list).begin();
24+
25+
if ((*list).size() > 1)
26+
{
27+
std::list<std::wstring>::iterator it = (*list).begin();
28+
it++;
29+
30+
for (it; it != (*list).end(); it++)
31+
ret += sep + (*it);
32+
}
33+
34+
return ret;
35+
}
36+
37+
38+
std::wstring ToLower(std::wstring val)
39+
{
40+
std::transform(val.begin(), val.end(), val.begin(), tolower);
41+
return val;
42+
}
43+
44+
45+
std::wstring GetExtNoDot(std::wstring pathName)
46+
{
47+
size_t period = pathName.find_last_of(L".");
48+
return ToLower(pathName.substr(period + 1));
49+
}
50+
51+
1652
BOOL FileExists(std::wstring file)
1753
{
1854
if (file.length() == 0)
@@ -23,6 +59,13 @@ BOOL FileExists(std::wstring file)
2359
}
2460

2561

62+
BOOL DirectoryExist(std::wstring path)
63+
{
64+
DWORD dwAttrib = GetFileAttributes(path.c_str());
65+
return (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
66+
}
67+
68+
2669
HBITMAP Create32BitHBITMAP(UINT cx, UINT cy, PBYTE* ppbBits)
2770
{
2871
BITMAPINFO bmi;
@@ -97,6 +140,15 @@ HRESULT SetIcon(HMENU menu, UINT position, UINT flags, Item* item)
97140
path = szPath;
98141
}
99142

143+
// starts with
144+
if (path.rfind(L"..\\", 0) == 0)
145+
{
146+
WCHAR szExeDir[500];
147+
SHRegGetPath(HKEY_CURRENT_USER, L"Software\\" PRODUCT_NAME, L"ExeDir", szExeDir, NULL);
148+
std::wstring exeDir(szExeDir);
149+
path = exeDir + path;
150+
}
151+
100152
if (!FileExists(path))
101153
return S_OK;
102154

@@ -128,47 +180,6 @@ HRESULT SetIcon(HMENU menu, UINT position, UINT flags, Item* item)
128180
}
129181

130182

131-
std::wstring JoinList(std::list<std::wstring>* list, const std::wstring& sep)
132-
{
133-
std::wstring ret;
134-
135-
if ((*list).size() > 0)
136-
ret = *(*list).begin();
137-
138-
if ((*list).size() > 1)
139-
{
140-
std::list<std::wstring>::iterator it = (*list).begin();
141-
it++;
142-
143-
for (it; it != (*list).end(); it++)
144-
ret += sep + (*it);
145-
}
146-
147-
return ret;
148-
}
149-
150-
151-
std::wstring ToLower(std::wstring val)
152-
{
153-
std::transform(val.begin(), val.end(), val.begin(), tolower);
154-
return val;
155-
}
156-
157-
158-
std::wstring GetExtNoDot(std::wstring pathName)
159-
{
160-
size_t period = pathName.find_last_of(L".");
161-
return ToLower(pathName.substr(period + 1));
162-
}
163-
164-
165-
BOOL DirectoryExist(std::wstring path)
166-
{
167-
DWORD dwAttrib = GetFileAttributes(path.c_str());
168-
return (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
169-
}
170-
171-
172183
HRESULT CMain::LoadXML()
173184
{
174185
for (Item* item : g_Items)
@@ -246,6 +257,8 @@ HRESULT CMain::LoadXML()
246257
item->IconIndex = std::stoi(std::wstring(cNodeText));
247258
else if (cNodeName == L"FileTypes")
248259
item->FileTypes = cNodeText;
260+
else if (cNodeName == L"Filter")
261+
item->Filter = cNodeText;
249262
else if (cNodeName == L"SubMenu")
250263
item->SubMenu = (cNodeText == L"true") ? true : false;
251264
else if (cNodeName == L"Directories")
@@ -348,6 +361,9 @@ STDMETHODIMP CMain::QueryContextMenu(
348361
bool isFile = FileExists(*g_ShellItems.begin());
349362
bool isDirectory = !isFile && DirectoryExist(*g_ShellItems.begin());
350363

364+
std::wstring ext = GetExtNoDot(*g_ShellItems.begin());
365+
std::wstring path = *g_ShellItems.begin();
366+
351367
g_EditCommandIndex = -1;
352368

353369
int res = InsertMenu(hmenu, uMenuIndex, MF_BYPOSITION | MF_POPUP, (UINT_PTR)subMenu, L"Open with++");
@@ -364,10 +380,10 @@ STDMETHODIMP CMain::QueryContextMenu(
364380
for (UINT i = 0; i < g_Items.size(); i++)
365381
{
366382
g_Items[i]->CommandIndex = -1;
367-
std::wstring ext = GetExtNoDot(*g_ShellItems.begin());
368383

369384
if (isFile && g_Items[i]->FileTypes != L"" && ext != L""
370385
&& (L" " + g_Items[i]->FileTypes + L" ").find(L" " + ext + L" ") != std::wstring::npos
386+
&& (g_Items[i]->Filter == L"" || std::regex_search(path, std::wregex(g_Items[i]->Filter)))
371387
&& (!g_Items[i]->Hidden || (g_Items[i]->Hidden && isCtrlPressed)))
372388
{
373389
g_Items[i]->CommandIndex = command - uidFirstCmd;
@@ -411,7 +427,8 @@ STDMETHODIMP CMain::QueryContextMenu(
411427

412428
for (UINT i = 0; i < g_Items.size(); i++)
413429
{
414-
if ((g_Items[i]->FileTypes == L"*.*" && isFile) || (g_Items[i]->Directories && isDirectory)
430+
if ((g_Items[i]->FileTypes == L"*.*" && isFile || g_Items[i]->Directories && isDirectory)
431+
&& (g_Items[i]->Filter == L"" || std::regex_search(path, std::wregex(g_Items[i]->Filter)))
415432
&& (!g_Items[i]->Hidden || (g_Items[i]->Hidden && isCtrlPressed)))
416433
{
417434
g_Items[i]->CommandIndex = command - uidFirstCmd;
@@ -503,6 +520,15 @@ STDMETHODIMP CMain::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
503520
args = value.GetBuffer();
504521
}
505522

523+
if (args.find(L"%filename-no-ext%") != std::wstring::npos)
524+
{
525+
std::wstring firstFile = g_ShellItems.front();
526+
std::filesystem::path fp(firstFile);
527+
ATL::CString value = args.c_str();
528+
value.Replace(L"%filename-no-ext%", fp.stem().c_str());
529+
args = value.GetBuffer();
530+
}
531+
506532
std::wstring verb;
507533

508534
if (g_Items[i]->RunAsAdmin || GetKeyState(VK_SHIFT) < 0)
@@ -520,6 +546,14 @@ STDMETHODIMP CMain::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
520546
path = szPath;
521547
}
522548

549+
WCHAR szExeDir[500];
550+
SHRegGetPath(HKEY_CURRENT_USER, L"Software\\" PRODUCT_NAME, L"ExeDir", szExeDir, NULL);
551+
std::wstring exeDir(szExeDir);
552+
553+
// starts with
554+
if (path.rfind(L"..\\", 0) == 0)
555+
path = exeDir + path;
556+
523557
if (args.find(var) != std::string::npos)
524558
{
525559
WCHAR szArgs[900];
@@ -532,12 +566,7 @@ STDMETHODIMP CMain::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
532566
std::wstring guiExe(L"OpenWithPPGUI.exe");
533567

534568
if (guiExe == path)
535-
{
536-
WCHAR szExeDir[500];
537-
SHRegGetPath(HKEY_CURRENT_USER, L"Software\\" PRODUCT_NAME, L"ExeDir", szExeDir, NULL);
538-
std::wstring exeDir(szExeDir);
539569
path = exeDir + guiExe;
540-
}
541570

542571
SHELLEXECUTEINFO info;
543572

OpenWithPPShellExtension/Main.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "Util.h"
55
#include "Common.h"
66

7-
87
EXTERN_C const CLSID CLSID_Main;
98

109
// {E7B8ACF5-FC18-4f0d-BC50-D0184481A5DC}
@@ -15,12 +14,13 @@ class Item
1514
public:
1615
HBITMAP Icon = NULL;
1716

17+
std::wstring Arguments;
18+
std::wstring FileTypes;
19+
std::wstring Filter;
20+
std::wstring IconFile;
1821
std::wstring Name;
1922
std::wstring Path;
20-
std::wstring Arguments;
2123
std::wstring WorkingDirectory;
22-
std::wstring IconFile;
23-
std::wstring FileTypes;
2424

2525
bool SubMenu;
2626
bool Directories;

0 commit comments

Comments
 (0)