Улучшен алгоритм настройки

This commit is contained in:
cfif 2025-04-24 12:17:48 +03:00
parent b15929a0ac
commit cc5daec86f
8 changed files with 83 additions and 10 deletions

View File

@ -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));

Binary file not shown.

Binary file not shown.

View File

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.