mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
check single-instance apps running
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "../projects-common/AppUtils.h"
|
||||||
#include "../projects-common/MonitorEnumerator.h"
|
#include "../projects-common/MonitorEnumerator.h"
|
||||||
#include "../projects-common/WindowEnumerator.h"
|
#include "../projects-common/WindowEnumerator.h"
|
||||||
#include "../projects-common/WindowFilter.h"
|
#include "../projects-common/WindowFilter.h"
|
||||||
@@ -280,10 +281,33 @@ bool Launch(const Project::Application& app)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The app wasn't launched, check if it's already launched for single-instance apps
|
||||||
if (launchedWindows.empty())
|
if (launchedWindows.empty())
|
||||||
{
|
{
|
||||||
std::wcout << L"Failed to launch " << app.name << std::endl;
|
std::wcout << L"Failed to launch " << app.name << L", checking if it's launched already." << std::endl;
|
||||||
return false;
|
|
||||||
|
auto apps = Utils::Apps::GetAppsList();
|
||||||
|
auto windows = WindowEnumerator::Enumerate(WindowFilter::Filter);
|
||||||
|
for (HWND window : windows)
|
||||||
|
{
|
||||||
|
std::wstring processPath = Common::Utils::ProcessPath::get_process_path_waiting_uwp(window);
|
||||||
|
auto data = Utils::Apps::GetApp(processPath, apps);
|
||||||
|
if (!data.has_value())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.value().name == app.name)
|
||||||
|
{
|
||||||
|
launchedWindows.push_back(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The single-instance app not found
|
||||||
|
if (launchedWindows.empty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place the window
|
// Place the window
|
||||||
|
|||||||
Reference in New Issue
Block a user