Skip to content

Commit

Permalink
Make delay after 5 seconds unblock ShowWindow()-function
Browse files Browse the repository at this point in the history
  • Loading branch information
d4koon committed Jan 9, 2022
1 parent 6b25aff commit 76aeb93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions WhatsappTray/Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <string>
#include <windows.h>
#include <future>
#include <thread>
#include <psapi.h> // OpenProcess()
#include <shobjidl.h> // For ITaskbarList3
//#include <shellscalingapi.h> // For dpi-scaling stuff
Expand Down Expand Up @@ -201,6 +202,9 @@ DWORD WINAPI Init(LPVOID lpParam)
return 5;
}

// This is a good point to see if WhatsApp is fully initialized, because it sets the overlay-icon very late in the init-process.
std::async(&OnWhatsAppFullyInitialized);

return 0;
}

Expand All @@ -211,6 +215,8 @@ void OnWhatsAppFullyInitialized()
{
LogString("WhatsAppFullyInitialized");

std::this_thread::sleep_for(std::chrono::seconds(5));

// It is no longer necessary to block the ShowWindow()-function, so unblock it again...
UnblockShowWindowFunction();
}
Expand Down Expand Up @@ -889,8 +895,5 @@ HRESULT Rerouted_SetOverlayIcon()
LogString("_setOverlayIconMemoryAddress=0x%llX", _setOverlayIconMemoryAddress);
auto result = ((HRESULT(*)(ITaskbarList3*, HWND, HICON, LPCWSTR))_setOverlayIconMemoryAddress)(_pTaskbarList, hwnd, hIcon, NULL);

// This is a good point to see if WhatsApp is fully initialized, because it sets the overlay-icon very late in the init-process.
std::async(&OnWhatsAppFullyInitialized);

return result;
}
2 changes: 1 addition & 1 deletion WhatsappTray/Version.rc2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define MAJOR 1
#define MINOR 9
#define PATCH 0
#define IS_DEBUG 4
#define IS_DEBUG 5

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
Expand Down

0 comments on commit 76aeb93

Please sign in to comment.