/NagScreen.pas

http://mytc.googlecode.com/ · Pascal · 70 lines · 64 code · 6 blank · 0 comment · 7 complexity · b77071883e94861b37d274b154f6013e MD5 · raw file

  1. unit NagScreen;
  2. interface
  3. uses
  4. Messages,
  5. Windows;
  6. procedure CloseNagScreen;
  7. implementation
  8. procedure CloseNagScreen;
  9. var
  10. NastyNagScreen: HWND;
  11. Notebook: HWND;
  12. Page: HWND;
  13. Panel: HWND;
  14. NumPanel: HWND;
  15. NumButton: HWND;
  16. NumText: string;
  17. RepeatCount: integer;
  18. begin
  19. while True do
  20. begin
  21. NastyNagScreen := 0;
  22. Notebook := 0;
  23. Page := 0;
  24. Panel := 0;
  25. NumPanel := 0;
  26. NumButton := 0;
  27. NumText := '';
  28. RepeatCount := 0;
  29. while (NastyNagScreen = 0) do
  30. begin
  31. NastyNagScreen := FindWindow('TNASTYNAGSCREEN', nil);
  32. Sleep(1);
  33. end;
  34. while (Notebook = 0) and (RepeatCount < 100) do
  35. begin
  36. Notebook := FindWindowEx(NastyNagScreen, 0, 'TNotebook', nil);
  37. Inc(RepeatCount);
  38. end;
  39. while (Page = 0) and (RepeatCount < 100) do
  40. begin
  41. Page := FindWindowEx(Notebook, 0, 'TPage', nil);
  42. Inc(RepeatCount);
  43. end;
  44. while (Panel = 0) and (RepeatCount < 100) do
  45. begin
  46. Panel := FindWindowEx(Page, 0, 'TPanel', nil);
  47. Inc(RepeatCount);
  48. end;
  49. while (NumPanel = 0) and (RepeatCount < 100) do
  50. begin
  51. NumPanel := FindWindowEx(Panel, 0, 'TPanel', nil);
  52. Inc(RepeatCount);
  53. end;
  54. while (NumButton = 0) and (RepeatCount < 100) do
  55. begin
  56. SetLength(NumText, SendMessage(NumPanel, WM_GETTEXTLENGTH, 0, 0));
  57. SendMessage(NumPanel, WM_GETTEXT, Length(NumText) + 1, LPARAM(NumText));
  58. NumButton := FindWindowEx(Panel, 0, 'TButton', PChar('&' + NumText));
  59. Inc(RepeatCount);
  60. end;
  61. SendMessage(NumButton, BM_CLICK, 0, 0);
  62. end;
  63. end;
  64. end.