Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 6068831

Browse files
committed
v0.3
1 parent 6a488af commit 6068831

2 files changed

Lines changed: 107 additions & 87 deletions

File tree

TAPdll/dllmain.cpp

Lines changed: 99 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using namespace winrt::Windows::UI::Xaml;
1919
using namespace winrt::Windows::UI::Xaml::Controls;
2020
using namespace winrt::Windows::UI::Xaml::Media;
2121

22-
DWORD dwRes = 0, dwSize = sizeof(DWORD), dwOpacity = 0, dwLuminosity = 0;
22+
DWORD dwRes = 0, dwSize = sizeof(DWORD), dwOpacity = 0, dwLuminosity = 0, dwHide = 0;
2323
typedef void (WINAPI* RtlGetVersion_FUNC) (OSVERSIONINFOEXW*);
2424
OSVERSIONINFOEX os;
2525

@@ -92,101 +92,115 @@ struct ExplorerTAP : winrt::implements<ExplorerTAP, IObjectWithSite>
9292
CoreDispatcher dispatcher = convert_from_abi<CoreDispatcher>(dispatcherPtr);
9393
RegGetValue(HKEY_CURRENT_USER, L"Software\\TranslucentSM", L"TintOpacity", RRF_RT_DWORD, NULL, &dwOpacity, &dwSize);
9494
RegGetValue(HKEY_CURRENT_USER, L"Software\\TranslucentSM", L"TintLuminosityOpacity", RRF_RT_DWORD, NULL, &dwLuminosity, &dwSize);
95+
RegGetValue(HKEY_CURRENT_USER, L"Software\\TranslucentSM", L"HideSearch", RRF_RT_DWORD, NULL, &dwHide, &dwSize);
9596

9697
dispatcher.RunAsync(CoreDispatcherPriority::Normal, []()
9798
{
9899
auto content = Window::Current().Content();
99100
// Search for AcrylicBorder name
100101
static auto acrylicBorder = FindDescendantByName(content, L"AcrylicBorder").as<Border>();
102+
static auto srchBox = FindDescendantByName(content, L"StartMenuSearchBox").as<Control>();
101103
if (acrylicBorder != nullptr)
102104
{
103-
if (dwOpacity > 10) dwOpacity = 10;
104-
if (dwLuminosity > 10) dwLuminosity = 10;
105-
acrylicBorder.Background().as<AcrylicBrush>().TintOpacity(double(dwOpacity) / 10);
106-
acrylicBorder.Background().as<AcrylicBrush>().TintLuminosityOpacity(double(dwLuminosity) / 10);
105+
if (dwOpacity > 100) dwOpacity = 100;
106+
if (dwLuminosity > 100) dwLuminosity = 100;
107+
acrylicBorder.Background().as<AcrylicBrush>().TintOpacity(double(dwOpacity) / 100);
108+
acrylicBorder.Background().as<AcrylicBrush>().TintLuminosityOpacity(double(dwLuminosity) / 100);
109+
if (dwHide == 1 && srchBox != nullptr)
110+
{
111+
srchBox.Visibility(Visibility::Collapsed);
112+
}
107113
}
108114
auto nvpane = FindDescendantByName(content, L"NavigationPanePlacesListView");
109115
auto rootpanel = FindDescendantByName(nvpane, L"Root");
110-
auto grid = VisualTreeHelper::GetChild(rootpanel, 0).as<Grid>();
111-
static auto srchBox = FindDescendantByName(content, L"StartMenuSearchBox").as<Control>();
112-
113-
Button bt;
114-
auto f = FontIcon();
115-
f.Glyph(L"\uE104");
116-
f.FontFamily(Media::FontFamily(L"Segoe Fluent Icons"));
117-
bt.Content(winrt::box_value(f));
118-
Thickness buttonMargin;
119-
buttonMargin.Left = -40;
120-
buttonMargin.Top = 0;
121-
buttonMargin.Right = 0;
122-
buttonMargin.Bottom = 0;
123-
bt.Margin(buttonMargin);
124-
Thickness buttonPad;
125-
buttonPad.Left = 8.2;
126-
buttonPad.Right = 8.2;
127-
buttonPad.Top = 8;
128-
buttonPad.Bottom = 8;
129-
bt.Padding(buttonPad);
130-
bt.Width(38);
131-
bt.FontFamily(Windows::UI::Xaml::Media::FontFamily(L"Segoe UI Semibold"));
132-
grid.Children().Append(bt);
133-
134-
auto stackPanel = StackPanel();
135-
136-
TextBlock tbx;
137-
tbx.FontFamily(Windows::UI::Xaml::Media::FontFamily(L"Segoe UI Variable"));
138-
tbx.FontSize(13.0);
139-
winrt::hstring hs = L"TintOpacity";
140-
tbx.Text(hs);
141-
stackPanel.Children().Append(tbx);
142-
143-
Slider slider;
144-
slider.Width(140);
145-
slider.Value(acrylicBorder.Background().as<AcrylicBrush>().TintOpacity() * 100);
146-
stackPanel.Children().Append(slider);
147-
148-
TextBlock tbx1;
149-
tbx1.FontFamily(Windows::UI::Xaml::Media::FontFamily(L"Segoe UI Variable"));
150-
tbx1.FontSize(13.0);
151-
winrt::hstring hs1 = L"TintLuminosityOpacity";
152-
tbx1.Text(hs1);
153-
stackPanel.Children().Append(tbx1);
154-
155-
Slider slider2;
156-
slider2.Width(140);
157-
slider2.Value(acrylicBorder.Background().as<AcrylicBrush>().TintLuminosityOpacity().Value() * 100);
158-
stackPanel.Children().Append(slider2);
159-
160-
slider.ValueChanged([](IInspectable const& sender, RoutedEventArgs const&) {
161-
auto sliderControl = sender.as<Slider>();
162-
double sliderValue = sliderControl.Value();
163-
acrylicBorder.Background().as<AcrylicBrush>().TintOpacity(double(sliderValue) / 100);
164-
});
165-
166-
slider2.ValueChanged([](IInspectable const& sender, RoutedEventArgs const&) {
167-
auto sliderControl = sender.as<Slider>();
168-
double sliderValue = sliderControl.Value();
169-
acrylicBorder.Background().as<AcrylicBrush>().TintLuminosityOpacity(double(sliderValue) / 100);
170-
});
171-
172-
173-
auto checkBox = CheckBox();
174-
checkBox.Content(box_value(L"Hide search box"));
175-
stackPanel.Children().Append(checkBox);
176-
177-
checkBox.Checked([](IInspectable const& sender, RoutedEventArgs const&) {
178-
auto checkbox = sender.as<CheckBox>();
179-
srchBox.Visibility(Visibility::Collapsed);
180-
});
181-
182-
checkBox.Unchecked([](IInspectable const& sender, RoutedEventArgs const&) {
183-
auto checkbox = sender.as<CheckBox>();
184-
srchBox.Visibility(Visibility::Visible);
185-
});
186-
187-
Flyout flyout;
188-
flyout.Content(stackPanel);
189-
bt.Flyout(flyout);
116+
if (rootpanel != nullptr)
117+
{
118+
auto grid = VisualTreeHelper::GetChild(rootpanel, 0).as<Grid>();
119+
if (grid != nullptr)
120+
{
121+
Button bt;
122+
auto f = FontIcon();
123+
f.Glyph(L"\uE104");
124+
f.FontFamily(Media::FontFamily(L"Segoe Fluent Icons"));
125+
bt.Content(winrt::box_value(f));
126+
Thickness buttonMargin{-40,0,0,0};
127+
bt.Margin(buttonMargin);
128+
Thickness buttonPad{8.2,8,8.2,8};
129+
bt.Padding(buttonPad);
130+
bt.Width(38);
131+
bt.FontFamily(Windows::UI::Xaml::Media::FontFamily(L"Segoe UI Semibold"));
132+
grid.Children().Append(bt);
133+
134+
auto stackPanel = StackPanel();
135+
136+
TextBlock tbx;
137+
tbx.FontFamily(Windows::UI::Xaml::Media::FontFamily(L"Segoe UI Variable"));
138+
tbx.FontSize(13.0);
139+
winrt::hstring hs = L"TintOpacity";
140+
tbx.Text(hs);
141+
stackPanel.Children().Append(tbx);
142+
143+
Slider slider;
144+
slider.Width(140);
145+
slider.Value(acrylicBorder.Background().as<AcrylicBrush>().TintOpacity() * 100);
146+
stackPanel.Children().Append(slider);
147+
148+
TextBlock tbx1;
149+
tbx1.FontFamily(Windows::UI::Xaml::Media::FontFamily(L"Segoe UI Variable"));
150+
tbx1.FontSize(13.0);
151+
winrt::hstring hs1 = L"TintLuminosityOpacity";
152+
tbx1.Text(hs1);
153+
stackPanel.Children().Append(tbx1);
154+
155+
Slider slider2;
156+
slider2.Width(140);
157+
slider2.Value(acrylicBorder.Background().as<AcrylicBrush>().TintLuminosityOpacity().Value() * 100);
158+
stackPanel.Children().Append(slider2);
159+
160+
static HKEY subKey = nullptr;
161+
DWORD dwSize = sizeof(DWORD), dwInstalled = 0;
162+
RegCreateKeyEx(HKEY_CURRENT_USER, L"SOFTWARE\\TranslucentSM", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &subKey, NULL);
163+
164+
slider.ValueChanged([](IInspectable const& sender, RoutedEventArgs const&) {
165+
auto sliderControl = sender.as<Slider>();
166+
double sliderValue = sliderControl.Value();
167+
DWORD val = sliderValue;
168+
acrylicBorder.Background().as<AcrylicBrush>().TintOpacity(double(sliderValue) / 100);
169+
RegSetValueEx(subKey, TEXT("TintOpacity"), 0, REG_DWORD, (const BYTE*)&val, sizeof(val));
170+
});
171+
172+
slider2.ValueChanged([](IInspectable const& sender, RoutedEventArgs const&) {
173+
auto sliderControl = sender.as<Slider>();
174+
double sliderValue = sliderControl.Value();
175+
DWORD val = sliderValue;
176+
acrylicBorder.Background().as<AcrylicBrush>().TintLuminosityOpacity(double(sliderValue) / 100);
177+
RegSetValueEx(subKey, TEXT("TintLuminosityOpacity"), 0, REG_DWORD, (const BYTE*)&val, sizeof(val));
178+
});
179+
180+
auto checkBox = CheckBox();
181+
checkBox.Content(box_value(L"Hide search box"));
182+
stackPanel.Children().Append(checkBox);
183+
if (dwHide == 1)
184+
{
185+
checkBox.IsChecked(true);
186+
}
187+
checkBox.Checked([](IInspectable const& sender, RoutedEventArgs const&) {
188+
DWORD ser = 1;
189+
RegSetValueEx(subKey, TEXT("HideSearch"), 0, REG_DWORD, (const BYTE*)&ser, sizeof(ser));
190+
srchBox.Visibility(Visibility::Collapsed);
191+
});
192+
193+
checkBox.Unchecked([](IInspectable const& sender, RoutedEventArgs const&) {
194+
DWORD ser = 0;
195+
RegSetValueEx(subKey, TEXT("HideSearch"), 0, REG_DWORD, (const BYTE*)&ser, sizeof(ser));
196+
srchBox.Visibility(Visibility::Visible);
197+
});
198+
199+
Flyout flyout;
200+
flyout.Content(stackPanel);
201+
bt.Flyout(flyout);
202+
}
203+
}
190204
});
191205
return S_OK;
192206
}

start/start.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,21 @@ int main()
211211
{
212212
std::cout << "\n- Created HKCU\\SOFTWARE\\TranslucentSM registry key.";
213213
RegistryGrantAll(subKey);
214-
DWORD opacity = 3;
214+
DWORD opacity = 30;
215215
RegSetValueEx(subKey, TEXT("TintOpacity"), 0, REG_DWORD, (const BYTE*)&opacity, sizeof(opacity));
216-
opacity = 0;
216+
opacity = 50;
217217
RegSetValueEx(subKey, TEXT("TintLuminosityOpacity"), 0, REG_DWORD, (const BYTE*)&opacity, sizeof(opacity));
218218
}
219219
else
220220
{
221221
std::cout << "\n- Opened HKCU\\SOFTWARE\\TranslucentSM registry key.";
222222
}
223+
DWORD ser = 0;
224+
if (ERROR_FILE_NOT_FOUND == RegGetValue(HKEY_CURRENT_USER, L"Software\\TranslucentSM", L"HideSearch", RRF_RT_DWORD, NULL, &ser, &dwSize))
225+
{
226+
RegSetValueEx(subKey, TEXT("HideSearch"), 0, REG_DWORD, (const BYTE*)&ser, sizeof(ser));
227+
}
228+
223229
RegCloseKey(subKey);
224230
SECURITY_ATTRIBUTES st;
225231
st.bInheritHandle = FALSE;

0 commit comments

Comments
 (0)