0

我正在尝试在网页上找到一个按钮并单击它。这是我试图为此制作的脚本:

IfWinExist, Google - Mozilla Firefox WinActivate ImageSearch, Foundx, Foundy, 18, 69, 371, 328, C:\users\bob\desktop\google.png 如果 ErrorLevel MsgBox, Image not found. 否则,鼠标移动

这显然不是我的实际脚本,但它是相同的命令。我想要一个脚本来定位页面上的图像,将鼠标移动到图像的中心,然后单击。我的脚本的问题是我无法保存找到的图像的坐标并将鼠标移动到它。

4

1 回答 1

0

您需要确定搜索表单是发出 POST 还是 GET 请求。GET 请求意味着在查询字符串中传递值。您可以通过 Google 看到这一点。您需要做的就是制定自己的查询字符串以包含搜索词并使用它创建一个 HttpWebRequest。如果是 POST 请求,则需要做一个稍微不同类型的 HttpWebRequest。它在 Form 集合而不是 QueryString 中传递值。

这是一篇基本使用 GET 请求的文章:http: //www.mikesdotnetting.com/Article/49/How-to-read-a-remote-web-page-with-ASP.NET-2.0。表单请求的方法如下:

public static string HttpPostRequest(string url, string post)
 {
   var encoding = new ASCIIEncoding();
   byte[] data = encoding.GetBytes(post);
   WebRequest request = WebRequest.Create(url);
   request.Method = "POST";
   request.ContentType = "application/x-www-form-urlencoded";
   request.ContentLength = data.Length;
   Stream stream = request.GetRequestStream();
   stream.Write(data, 0, data.Length);
   stream.Close();
   WebResponse response = request.GetResponse();
   String result;
   using (var sr = new StreamReader(response.GetResponseStream()))
   {
     result = sr.ReadToEnd();
     sr.Close();
   }
   return result;
 }

来自“Mikesdotnetting”的答案:http ://forums.asp.net/t/1495798.aspx/1

于 2013-08-25T08:07:49.467 回答