Opening settings when user is opening already running Powertoys (#1957)

* Added code to open general settings when opening second instance of powertoys
This commit is contained in:
Yevhenii Holovachov
2020-04-07 13:17:18 +03:00
committed by GitHub
parent f5ed9f1c33
commit de42d9f310

View File

@@ -149,12 +149,11 @@ void github_update_checking_worker()
state.save(); state.save();
} }
} }
void alert_already_running()
void open_menu_from_another_instance()
{ {
MessageBoxW(nullptr, HWND hwnd_main = FindWindow(L"PToyTrayIconWindow", NULL);
GET_RESOURCE_STRING(IDS_ANOTHER_INSTANCE_RUNNING).c_str(), PostMessage(hwnd_main, WM_COMMAND, ID_SETTINGS_MENU_COMMAND, NULL);
GET_RESOURCE_STRING(IDS_POWERTOYS).c_str(),
MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND);
} }
int runner(bool isProcessElevated) int runner(bool isProcessElevated)
@@ -320,7 +319,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (!msix_mutex) if (!msix_mutex)
{ {
// The MSIX version is already running. // The MSIX version is already running.
alert_already_running(); open_menu_from_another_instance();
return 0; return 0;
} }
@@ -337,7 +336,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
msi_mutex = create_msi_mutex(); msi_mutex = create_msi_mutex();
if (!msi_mutex) if (!msi_mutex)
{ {
alert_already_running(); open_menu_from_another_instance();
return 0; return 0;
} }
} }
@@ -355,7 +354,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (!msi_mutex) if (!msi_mutex)
{ {
// The MSI version is already running. // The MSI version is already running.
alert_already_running(); open_menu_from_another_instance();
return 0; return 0;
} }
@@ -366,7 +365,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (!msix_mutex) if (!msix_mutex)
{ {
// The MSIX version is already running. // The MSIX version is already running.
alert_already_running(); open_menu_from_another_instance();
return 0; return 0;
} }
else else