| 106 | } |
| 107 | |
| 108 | static bool FindWindowProc(IntPtr hWnd, IntPtr lParam) |
| 109 | { |
| 110 | GetWindowThreadProcessId(hWnd, out int procId); |
| 111 | if (procId != Process.GetCurrentProcess().Id) return true; |
| 112 | if (!IsWindowVisible(hWnd)) return true; |
| 113 | var l = GetWindowTextLength(hWnd); |
| 114 | if (l == 0) return true; |
| 115 | var builder = new StringBuilder(l + 1); |
| 116 | GetWindowText(hWnd, builder, builder.Capacity); |
| 117 | if (builder.ToString() == "World of Warcraft") |
| 118 | windowHandle = (int)hWnd; |
| 119 | return true; |
| 120 | } |
| 121 | |
| 122 | static void SendUserMessage() => SendMessage(windowHandle, WM_USER, 0, 0); |
| 123 | } |