如题,我想“自动的”去做一些事情,比如说在百度的输入框中,这个脚本或者程序去读取文件里面的一行字符串,然后这行字符串放到搜索框中,再点击搜索,请问可以做到这样的东西吗?又应该用什么语言来编写呢?
国产的有按键精灵、“易语言”,国外有autoit,它们都可以实现你的需求,而且几乎不要编程。
编程语言里,vb C# 可以使用 webbrowser 实现,vc++可以使用 chtmlctrl类,java有webview,python有Selenium 库
以上提到的,你google下,就能找到。
采纳本回答,另外送你python vc++ vb等开发技术电子书一些。
用python吧
如果是百度那么几行代码就够了 如下:
至于会报错什么的那一定是你的环境没有配置好,我这里是可以运行的,有问题继续问!!
用C#帮你做了一个简单的演示
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace Q690252
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.google.com");
while (true)
{
Application.DoEvents();
if (webBrowser1.Document != null)
{
dynamic q = webBrowser1.Document.All["q"];
if (q != null)
{
q.InnerText = textBox1.Text;
break;
}
}
}
Thread.Sleep(2000);
HtmlElement b = webBrowser1.Document.All.Cast<HtmlElement>().First(x => (x.GetAttribute("name") ?? "") == "btnK");
b.InvokeMember("click");
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.baidu.com");
while (true)
{
Application.DoEvents();
if (webBrowser1.Document != null)
{
dynamic q = webBrowser1.Document.All["kw"];
if (q != null)
{
q.InnerText = textBox1.Text;
break;
}
}
}
Thread.Sleep(2000);
HtmlElement b = webBrowser1.Document.All["su"];
b.InvokeMember("click");
}
}
}
我觉得用按键精灵最方便,可以搜索一下。
C#不但可以操纵浏览器,还可以操纵任意软件
下面演示如何打开记事本,自动输入一段文本