| 448 | } |
| 449 | |
| 450 | static HWND |
| 451 | GetConsoleHwnd(void) |
| 452 | { |
| 453 | int iterations = 0; |
| 454 | HWND hwndFound = 0; |
| 455 | char OldTitle[1024], NewTitle[1024], TestTitle[1024]; |
| 456 | |
| 457 | /* Get current window title */ |
| 458 | GetConsoleTitle(OldTitle, sizeof OldTitle); |
| 459 | |
| 460 | (void) sprintf(NewTitle, "NETHACK%lld/%ld", GetTickCount64(), |
| 461 | GetCurrentProcessId()); |
| 462 | SetConsoleTitle(NewTitle); |
| 463 | |
| 464 | GetConsoleTitle(TestTitle, sizeof TestTitle); |
| 465 | while (strcmp(TestTitle, NewTitle) != 0) { |
| 466 | iterations++; |
| 467 | /* sleep(0); */ |
| 468 | GetConsoleTitle(TestTitle, sizeof TestTitle); |
| 469 | } |
| 470 | hwndFound = FindWindow(NULL, NewTitle); |
| 471 | SetConsoleTitle(OldTitle); |
| 472 | /* printf("%d iterations\n", iterations); */ |
| 473 | return hwndFound; |
| 474 | } |
| 475 | #endif /* 0 */ |
| 476 | #endif /* WIN32CON */ |
| 477 | #endif /* RUNTIME_PASTEBUF_SUPPORT */ |