Some fixes.

This commit is contained in:
2023-11-28 17:34:55 +03:00
parent 2d90c60a1c
commit febb3bda2f
3 changed files with 23 additions and 29 deletions

View File

@@ -40,7 +40,7 @@ function makeVersionString([string]$vmaj, [string]$vmin, [string]$vbld, [string]
} }
#region Initializing variables #region Initializing variables
[string]$verMajor = [string]$verMinor = [string]$verBuild = [string]$verRevision = $null [string]$verMajor = [string]$verMinor = [string]$verBuild = [string]$verPatch = $null
[string]$pn = [string]$pa = [string]$aboutBuild = [string]$pnf = [string]$pcf = $null [string]$pn = [string]$pa = [string]$aboutBuild = [string]$pnf = [string]$pcf = $null
[string]$buildDateTime = [string]$vs = [string]$vn = [string]$intName = [string]$origName = $null [string]$buildDateTime = [string]$vs = [string]$vn = [string]$intName = [string]$origName = $null
[int]$pys = [int]$spanDays = [int]$spanSecs = $null [int]$pys = [int]$spanDays = [int]$spanSecs = $null
@@ -80,7 +80,7 @@ $config = (Get-IniContent -FilePath $iniFile)["Config"]
$verMajor = $config.Major $verMajor = $config.Major
$verMinor = $config.Minor $verMinor = $config.Minor
$verBuild = $config.Build $verBuild = $config.Build
$verRevision = $config.Revision $verPatch = $config.Patch
$pys = $config.ProductYearStart $pys = $config.ProductYearStart
$pn = $config.ProductName $pn = $config.ProductName
$pa = $config.ProductAutors $pa = $config.ProductAutors
@@ -109,11 +109,11 @@ $origName = "$pn.exe"
$verMajor = getValue $verMajor $verMajor = getValue $verMajor
$verMinor = getValue $verMinor $verMinor = getValue $verMinor
$verBuild = getValue $verBuild $verBuild = getValue $verBuild
$verRevision = getValue $verRevision $verPatch = getValue $verPatch
#endregion #endregion
$vs = (makeVersionString $verMajor $verMinor $verBuild $verRevision)[0] $vs = (makeVersionString $verMajor $verMinor $verBuild $verPatch)[0]
$vn = (makeVersionString $verMajor $verMinor $verBuild $verRevision)[1] $vn = (makeVersionString $verMajor $verMinor $verBuild $verPatch)[1]
# if ([string]::IsNullOrEmpty($gitVerStr)) { $pnf = "$pn v$vs" } else { $pnf = "$pn $gitVerStr" } # if ([string]::IsNullOrEmpty($gitVerStr)) { $pnf = "$pn v$vs" } else { $pnf = "$pn $gitVerStr" }
if ($isGit) { if ($isGit) {
@@ -154,7 +154,7 @@ else {
# echo " verMajor: [$verMajor]" # echo " verMajor: [$verMajor]"
# echo " verMinor: [$verMinor]" # echo " verMinor: [$verMinor]"
# echo " verBuild: [$verBuild]" # echo " verBuild: [$verBuild]"
# echo " verRevision: [$verRevision]" # echo " verPatch: [$verPatch]"
# echo "" # echo ""
# echo " aboutBuild: [$aboutBuild]" # echo " aboutBuild: [$aboutBuild]"
# echo " productNameFull: [$pnf]" # echo " productNameFull: [$pnf]"

Binary file not shown.

View File

@@ -14,18 +14,18 @@
#define KEY_C 0x43 #define KEY_C 0x43
#define KEY_V 0x56 #define KEY_V 0x56
#define BUF_LEN 1024 #define MAX_WINTITLE_BUFFER_LENGTH 1024
#define WM_WCW (WM_APP + 0x0F00) #define WM_WCW (WM_APP + 0x0F00)
// Global variables: // Global variables:
HINSTANCE hInst; // Instance HINSTANCE hInst; // Instance
WCHAR szTitle[MAX_LOADSTRING]; // wCenterWindow's title WCHAR szTitle[MAX_LOADSTRING]{ 0 }; // wCenterWindow's title
WCHAR szClass[MAX_LOADSTRING]; // Window's class WCHAR szClass[MAX_LOADSTRING]{ 0 }; // Window's class
WCHAR szWinTitle[256]; WCHAR szWinTitle[256]{ 0 };
WCHAR szWinClass[256]; WCHAR szWinClass[256]{ 0 };
HANDLE hHeap = NULL, hUpdater = NULL; HANDLE hHeap = NULL, hUpdater = NULL;
UINT dwUpdaterID = 0; UINT dwUpdaterID = 0;
HHOOK hMouseHook = NULL, hKbdHook = NULL; // Hook's handles HHOOK hMouseHook = NULL, hKbdHook = NULL; // Hook's handles
HICON hIcon = NULL; HICON hIcon = NULL;
HMENU hMenu = NULL, hPopup = NULL; HMENU hMenu = NULL, hPopup = NULL;
HWND hWnd = NULL, hFgWnd = NULL; HWND hWnd = NULL, hFgWnd = NULL;
@@ -157,7 +157,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
HandlingTrayIcon(); HandlingTrayIcon();
hHeap = GetProcessHeap(); hHeap = GetProcessHeap();
szBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, BUF_LEN); szBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, MAX_WINTITLE_BUFFER_LENGTH);
MSG msg; MSG msg;
BOOL bRet; BOOL bRet;
@@ -204,7 +204,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
logger.Out(L"%s(%d): Loading context menu failed!", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Loading context menu failed!", TEXT(__FUNCTION__), __LINE__);
ShowError(IDS_ERR_MENU); ShowError(IDS_ERR_MENU);
PostQuitMessage(0); PostQuitMessage(0);
//PostMessageW(hWnd, WM_CLOSE, NULL, NULL);
} }
logger.Out(L"%s(%d): Context menu successfully loaded", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Context menu successfully loaded", TEXT(__FUNCTION__), __LINE__);
@@ -214,7 +213,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
logger.Out(L"%s(%d): Creating popup menu failed!", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Creating popup menu failed!", TEXT(__FUNCTION__), __LINE__);
ShowError(IDS_ERR_POPUP); ShowError(IDS_ERR_POPUP);
PostQuitMessage(0); PostQuitMessage(0);
//PostMessageW(hWnd, WM_CLOSE, NULL, NULL);
} }
logger.Out(L"%s(%d): Popup menu successfully created", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Popup menu successfully created", TEXT(__FUNCTION__), __LINE__);
@@ -234,7 +232,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (fCheckUpdates) if (fCheckUpdates)
{ {
if (!SetTimer(hWnd, IDT_TIMER, 20000, NULL)) // 20 seconds if (!SetTimer(hWnd, IDT_TIMER, 20000, NULL)) // 20 seconds
{ {
logger.Out(L"%s(%d): Creating timer failed!", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Creating timer failed!", TEXT(__FUNCTION__), __LINE__);
ShowError(IDS_ERR_TIMER); ShowError(IDS_ERR_TIMER);
@@ -251,7 +249,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ShowError(IDS_ERR_HOOK); ShowError(IDS_ERR_HOOK);
PostQuitMessage(0); PostQuitMessage(0);
//PostMessageW(hWnd, WM_CLOSE, NULL, NULL);
} }
logger.Out(L"%s(%d): The mouse hook was successfully installed", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): The mouse hook was successfully installed", TEXT(__FUNCTION__), __LINE__);
#endif // !_DEBUG #endif // !_DEBUG
@@ -263,7 +260,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ShowError(IDS_ERR_HOOK); ShowError(IDS_ERR_HOOK);
PostQuitMessage(0); PostQuitMessage(0);
//PostMessageW(hWnd, WM_CLOSE, NULL, NULL);
} }
logger.Out(L"%s(%d): The keyboard hook was successfully installed", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): The keyboard hook was successfully installed", TEXT(__FUNCTION__), __LINE__);
break; break;
@@ -273,11 +269,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
if (fCheckUpdates) if (fCheckUpdates)
{ {
Sleep(10000); // 10 seconds Sleep(10000); // 10 seconds
logger.Out(L"%s(%d): Checking for updates is enabled, fCheckUpdates = %s", TEXT(__FUNCTION__), __LINE__, fCheckUpdates ? L"True" : L"False"); logger.Out(L"%s(%d): Checking for updates is enabled, fCheckUpdates = %s", TEXT(__FUNCTION__), __LINE__, fCheckUpdates ? L"True" : L"False");
//hUpdater = CreateThread(NULL, 0, &Updater, nullptr, 0, nullptr);
//hUpdater = (HANDLE)_beginthreadex(NULL, 0, &Updater, NULL, 0, &dwUpdaterID); //hUpdater = (HANDLE)_beginthreadex(NULL, 0, &Updater, NULL, 0, &dwUpdaterID);
if (NULL == hUpdater) if (NULL == hUpdater)
{ {
@@ -286,7 +281,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
else else
{ {
if (!SetTimer(hWnd, IDT_TIMER, 86390000, NULL)) // 1 day - 10 seconds if (!SetTimer(hWnd, IDT_TIMER, 86390000, NULL)) // 1 day - 10 seconds
{ {
logger.Out(L"%s(%d): Creating timer failed!", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Creating timer failed!", TEXT(__FUNCTION__), __LINE__);
ShowError(IDS_ERR_TIMER); ShowError(IDS_ERR_TIMER);
@@ -302,7 +297,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
} }
case WM_WCW: // Popup menu handler case WM_WCW: // Popup menu handler
{ {
if (IDI_TRAYICON == wParam && (WM_RBUTTONDOWN == lParam || WM_LBUTTONDOWN == lParam)) if (IDI_TRAYICON == wParam && (WM_RBUTTONDOWN == lParam || WM_LBUTTONDOWN == lParam))
{ {
@@ -341,7 +336,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
logger.Out(L"%s(%d): Pressed the 'Exit' menuitem", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Pressed the 'Exit' menuitem", TEXT(__FUNCTION__), __LINE__);
PostQuitMessage(0); PostQuitMessage(0);
//PostMessageW(hWnd, WM_CLOSE, NULL, NULL);
} }
logger.Out(L"%s(%d): Exit from the WM_WCW message handler", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Exit from the WM_WCW message handler", TEXT(__FUNCTION__), __LINE__);
@@ -402,7 +396,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
if (VK_LCONTROL == pkhs->vkCode) bLCTRL = TRUE; if (VK_LCONTROL == pkhs->vkCode) bLCTRL = TRUE;
if (VK_LWIN == pkhs->vkCode) bLWIN = TRUE; if (VK_LWIN == pkhs->vkCode) bLWIN = TRUE;
if (KEY_I == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed) // 'I' key if (KEY_I == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed) // 'I' key
{ {
logger.Out(L"%s(%d): Pressed LCTRL + LWIN + I", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Pressed LCTRL + LWIN + I", TEXT(__FUNCTION__), __LINE__);
@@ -412,7 +406,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
} }
if (KEY_C == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed && !bKEYV) // 'C' key if (KEY_C == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed && !bKEYV) // 'C' key
{ {
logger.Out(L"%s(%d): Pressed LCTRL + LWIN + C", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Pressed LCTRL + LWIN + C", TEXT(__FUNCTION__), __LINE__);
@@ -423,7 +417,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
} }
if (KEY_V == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed && !bKEYV) // 'V' key if (KEY_V == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed && !bKEYV) // 'V' key
{ {
logger.Out(L"%s(%d): Pressed LCTRL + LWIN + V", TEXT(__FUNCTION__), __LINE__); logger.Out(L"%s(%d): Pressed LCTRL + LWIN + V", TEXT(__FUNCTION__), __LINE__);
@@ -515,7 +509,7 @@ BOOL IsWindowApprooved(HWND hFW)
bool bApprooved = FALSE; bool bApprooved = FALSE;
if (hFW) if (hFW)
{ {
if (GetWindowTextW(hFW, (LPWSTR)szBuffer, BUF_LEN - sizeof(WCHAR))) if (GetWindowTextW(hFW, (LPWSTR)szBuffer, MAX_WINTITLE_BUFFER_LENGTH))
{ {
logger.Out(L"%s(%d): Window title: '%s'", TEXT(__FUNCTION__), __LINE__, (LPWSTR)szBuffer); logger.Out(L"%s(%d): Window title: '%s'", TEXT(__FUNCTION__), __LINE__, (LPWSTR)szBuffer);
} }
@@ -592,7 +586,7 @@ VOID HandlingTrayIcon()
VOID ShowError(UINT uID) VOID ShowError(UINT uID)
{ {
WCHAR szErrorText[MAX_LOADSTRING]; // Error's text WCHAR szErrorText[MAX_LOADSTRING]; // Error's text
LoadStringW(hInst, uID, szErrorText, _countof(szErrorText)); LoadStringW(hInst, uID, szErrorText, _countof(szErrorText));
MessageBoxW(NULL, szErrorText, szTitle, MB_OK | MB_ICONERROR | MB_TOPMOST); MessageBoxW(NULL, szErrorText, szTitle, MB_OK | MB_ICONERROR | MB_TOPMOST);
} }