diff --git a/Compare.c b/Compare.c index 7a69bf5..9695924 100644 --- a/Compare.c +++ b/Compare.c @@ -24,8 +24,48 @@ typedef struct { wchar_t captionWindow[_MAX_PATH]; wchar_t pathWav1[_MAX_PATH]; wchar_t pathWav2[_MAX_PATH]; + BOOL error; } tCompareStruct; + +static BOOL setTextHwnd(HWND hwnd, LPCWSTR text1, int timeout) { + + wchar_t text2[_MAX_PATH]; + wcscpy_s(text2, _MAX_PATH, L" "); + + for (int i = 0; i < timeout; ++i) { + + SendMessage(hwnd, WM_SETTEXT, 0, text1); + SendMessage(hwnd, WM_GETTEXT, _MAX_PATH, text2); + + if (wcscmp(text1, text2) == 0) { + return FALSE; + } else { + Sleep(100); + } + } + + return TRUE; +} + +static BOOL setComboBoxHwnd(HWND hwnd, int index1, int timeout) { + + for (int i = 0; i < timeout; ++i) { + + ComboBox_SetCurSel(hwnd, index1); + int index2 = ComboBox_GetCurSel(hwnd); + + if (index1 == index2) { + return FALSE; + } + else { + Sleep(100); + } + } + + return TRUE; +} + static BOOL CALLBACK enum_wnd_proc(HWND hwnd, LPARAM lParam) { tCompareStruct* compareStruct = (tCompareStruct*)lParam; @@ -48,32 +88,50 @@ static BOOL CALLBACK enum_wnd_proc(HWND hwnd, LPARAM lParam) { #ifdef DEBUG_PRINTF printf("Edit1 found!\n"); #endif - SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)compareStruct->pathWav1); + compareStruct->error = setTextHwnd(hwnd, compareStruct->pathWav1, 50); + if (compareStruct->error) { + printf("Error: Edit1\n"); + return FALSE; + } } if ((wcscmp(classText, L"Edit") == 0) && (LocalTop == 73)) { #ifdef DEBUG_PRINTF printf("Edit2 found!\n"); #endif - SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)compareStruct->pathWav2); + compareStruct->error = setTextHwnd(hwnd, compareStruct->pathWav2, 50); + if (compareStruct->error) { + printf("Error: Edit2\n"); + return FALSE; + } } if ((wcscmp(classText, L"ComboBox") == 0) && (LocalTop == 109)) { #ifdef DEBUG_PRINTF printf("ComboBox1 found!\n"); #endif - ComboBox_SetCurSel(hwnd, 1); + compareStruct->error = setComboBoxHwnd(hwnd, 1, 50); + + if (compareStruct->error) { + printf("Error: ComboBox1\n"); + return FALSE; + } } if ((wcscmp(classText, L"ComboBox") == 0) && (LocalTop == 184)) { #ifdef DEBUG_PRINTF printf("ComboBox2 found!\n"); #endif - ComboBox_SetCurSel(hwnd, 1); + compareStruct->error = setComboBoxHwnd(hwnd, 1, 50); + + if (compareStruct->error) { + printf("Error: ComboBox2\n"); + return FALSE; + } } if ((wcscmp(classText, L"Static") == 0) && (LocalTop == 218)) { @@ -83,7 +141,12 @@ static BOOL CALLBACK enum_wnd_proc(HWND hwnd, LPARAM lParam) { wchar_t text[_MAX_PATH]; wcscpy_s(text, _MAX_PATH, L" -200.0%"); - SetWindowTextW(hwnd, (LPCWSTR)text); + compareStruct->error = setTextHwnd(hwnd, text, 50); + + if (compareStruct->error) { + printf("Error: Static\n"); + return FALSE; + } } } @@ -112,9 +175,10 @@ static BOOL CALLBACK enum_wnd_proc(HWND hwnd, LPARAM lParam) { printf("Static found!\n"); #endif wchar_t text[_MAX_PATH]; + wcscpy_s(text, _MAX_PATH, L" "); for (int i = 0; i < 50; ++i) { - GetWindowTextW(hwnd, (LPCWSTR)text, _MAX_PATH); + SendMessage(hwnd, WM_GETTEXT, _MAX_PATH, text); if (wcscmp(text, L" -200.0%") == 0) { Sleep(100); @@ -145,10 +209,12 @@ static void CALLBACK TimerUpdate(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw return; } -int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) { +static int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) { tCompareStruct compareStruct; + compareStruct.error = FALSE; + wchar_t captionWindow[_MAX_PATH]; wcscpy_s(captionWindow, _MAX_PATH, L"Sound-Similar 1.1 (Free Version) by Virtins Technology"); @@ -196,7 +262,8 @@ int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) { compareStruct.regim = REGIM_INIT; EnumChildWindows(hwnd, enum_wnd_proc, (LPARAM)(&compareStruct)); - Sleep(200); + if (compareStruct.error) + return 3; compareStruct.regim = REGIM_COMPARE; EnumChildWindows(hwnd, enum_wnd_proc, (LPARAM)(&compareStruct)); diff --git a/Compare/Release/Compare.iobj b/Compare/Release/Compare.iobj index 2570f9f..f37c53a 100644 Binary files a/Compare/Release/Compare.iobj and b/Compare/Release/Compare.iobj differ diff --git a/Compare/Release/Compare.ipdb b/Compare/Release/Compare.ipdb index 93f9dda..8885643 100644 Binary files a/Compare/Release/Compare.ipdb and b/Compare/Release/Compare.ipdb differ diff --git a/Compare/Release/Compare.log b/Compare/Release/Compare.log index 7d7cc48..99b90c1 100644 --- a/Compare/Release/Compare.log +++ b/Compare/Release/Compare.log @@ -1,8 +1,14 @@  Compare.c -C:\VC\Compare\Compare.c(117,39): warning C4090: функция: разные квалификаторы "const" +C:\VC\Compare\Compare.c(38,36): warning C4047: функция: "LPARAM" отличается по уровням косвенного обращения от "LPCWSTR" +C:\VC\Compare\Compare.c(38,36): warning C4024: SendMessageW: различные типы для формального и фактического параметров 4 +C:\VC\Compare\Compare.c(39,44): warning C4047: функция: "LPARAM" отличается по уровням косвенного обращения от "wchar_t [260]" +C:\VC\Compare\Compare.c(39,44): warning C4024: SendMessageW: различные типы для формального и фактического параметров 4 +C:\VC\Compare\Compare.c(181,46): warning C4047: функция: "LPARAM" отличается по уровням косвенного обращения от "wchar_t [260]" +C:\VC\Compare\Compare.c(181,46): warning C4024: SendMessageW: различные типы для формального и фактического параметров 4 +C:\VC\Compare\Compare.c(295,1): warning C4008: wmain: пропуск атрибута "static" Создание кода Создание кода завершено - 0 of 6 functions ( 0.0%) were compiled, the rest were copied from previous compilation. + 2 of 8 functions (25.0%) were compiled, the rest were copied from previous compilation. 0 functions were new in current compilation 0 functions had inline decision re-evaluated but remain unchanged Compare.vcxproj -> C:\VC\Compare\Release\Compare.exe diff --git a/Compare/Release/Compare.obj b/Compare/Release/Compare.obj index 9e1bf85..c633c0e 100644 Binary files a/Compare/Release/Compare.obj and b/Compare/Release/Compare.obj differ diff --git a/Compare/Release/vc143.pdb b/Compare/Release/vc143.pdb index 6f0c35d..25d7bf6 100644 Binary files a/Compare/Release/vc143.pdb and b/Compare/Release/vc143.pdb differ diff --git a/Release/Compare.exe b/Release/Compare.exe index 140beac..19e3839 100644 Binary files a/Release/Compare.exe and b/Release/Compare.exe differ diff --git a/Release/Compare.pdb b/Release/Compare.pdb index a3fbc62..6f576e9 100644 Binary files a/Release/Compare.pdb and b/Release/Compare.pdb differ