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

Fixed execution of task manager on Windows 11 24H2 #1093

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions mods/taskbar-empty-space-clicks.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id taskbar-empty-space-clicks
// @name Click on empty taskbar space
// @description Trigger custom action when empty space on a taskbar is double/middle clicked
// @version 1.4
// @version 1.5
// @author m1lhaus
// @github https://github.com/m1lhaus
// @include explorer.exe
Expand Down Expand Up @@ -1754,12 +1754,22 @@ void OpenTaskManager(HWND taskbarhWnd)
{
LOG_TRACE();

LOG_INFO(L"Sending OpenTaskManager message");
// https://www.codeproject.com/Articles/14380/Manipulating-The-Windows-Taskbar
if (SendMessage(taskbarhWnd, WM_COMMAND, MAKELONG(420, 0), 0) != 0)
{
LOG_ERROR(L"Failed to send OpenTaskManager message");
}
LOG_INFO(L"Opening Taskmgr.exe using ShellExecuteEx");
std::wstring taskmgrPath = L"C:\\Windows\\System32\\Taskmgr.exe";
m1lhaus marked this conversation as resolved.
Show resolved Hide resolved

SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.lpVerb = L"open"; // Use "runas" to explicitly request elevation
sei.lpFile = taskmgrPath.c_str();
sei.nShow = SW_SHOW;

if (!ShellExecuteEx(&sei))
{
DWORD error = GetLastError();
if (error != ERROR_CANCELLED) // User declined the elevation.
{
LOG_ERROR(L"Failed to start process taskmgr.exe with error code: %d", error);
}
}
}

void ToggleVolMuted()
Expand Down Expand Up @@ -1912,7 +1922,8 @@ void StartProcess(const std::wstring &command)

if (!CreateProcess(NULL, (LPWSTR)command.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
LOG_ERROR(L"Failed to start process - CreateProcess failed!");
DWORD error = GetLastError();
LOG_ERROR(L"Failed to start process - CreateProcess failed with error code: %d", error);
}
else
{
Expand Down