private static IntPtr FindPasswordWindow() { IntPtr password_handle = (IntPtr)0; int i = 0; while (true) { password_handle = Win32ApiTools.GetWindowHandle("", "Chrome_WidgetWin_1"); RECT rc = Win32ApiTools.GetWindowRect(password_handle); int width = rc.Right - rc.Left; //窗口的宽度 int height = rc.Bottom - rc.Top; //窗口的高度 int x = rc.Left; int y = rc.Top; if (width > 100 && height > 80) { break; } else { password_handle = (IntPtr)0; } i++; if (i > 30) { throw new Exception("出现异常,已退出自动转账!"); } Thread.Sleep(500); } return(password_handle); }
private static bool ConfirmSuccess() { IntPtr password_handle = (IntPtr)0; int i = 0; while (true) { password_handle = Win32ApiTools.GetWindowHandle("", "Chrome_WidgetWin_1"); RECT rc = Win32ApiTools.GetWindowRect(password_handle); int width = rc.Right - rc.Left; //窗口的宽度 int height = rc.Bottom - rc.Top; //窗口的高度 int x = rc.Left; int y = rc.Top; if (width <= 100 && height <= 80) { return(true); } else { Thread.Sleep(500); i++; } if (i > 20) { return(false); } } }