110,566
社区成员
发帖
与我相关
我的任务
分享
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.IO;
namespace xue
{
public partial class Form1 : Form
{
string[] p;//数组p就是要学习的课程编号集合
int meike = 3000000; //设定每课需要的的时间,6000毫秒等于1分钟
int dati = 6000; //设定答题间隔时间 1分钟
int keshu = 0; //定义总的学习课数目,等于数组的长度
int i = 0;//临时变量,用于定时器计数停止
public Form1()
{
InitializeComponent();
//从文件kejian.txt中读取课件的编号
StreamReader sr = new StreamReader("kejian.txt", Encoding.Default);
String line= sr.ReadLine().ToString();
p = line.Split(',');
keshu = p.Count();//将数组的元素数赋值到学习课数目
}
private void button1_Click(object sender, EventArgs e)
{
//
timer2.Interval = meike;//timer2每隔50分钟学完一课进入下一课
timer2.Start();
//第一次先学第一课,总不能傻傻的等50分钟吧
string url = "http://www.mwangxiao.com/play.aspx?course_id=" + p[i];
webBrowser1.Navigate(url);
//开启1分钟自动答题一次
timer1.Interval = dati;
timer1.Start();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void f()
{
this.webBrowser1.Select();
this.webBrowser1.Focus();
SendKeys.SendWait("{TAB}");//移动到A
SendKeys.SendWait("{ENTER}"); //选中A
SendKeys.SendWait("{TAB}");//
SendKeys.SendWait("{TAB}");//移动到C
SendKeys.SendWait("{ENTER}");//选中C
SendKeys.SendWait("{TAB}");//移动到D
SendKeys.SendWait("{ENTER}");//选中D
SendKeys.SendWait("{TAB}");//移动到提交
SendKeys.SendWait("{ENTER}");//点击提交
SendKeys.SendWait("{TAB}");
SendKeys.SendWait("{ENTER}");//点击下一小节学习
}
public void play()
{
i++;
string url = "http://www.mwangxiao.com/play.aspx?course_id=" + p[i];
webBrowser1.Navigate(url);
}
private void button3_Click(object sender, EventArgs e)
{
//点击登录按钮,进入登陆界面登录
webBrowser1.Navigate("http://113.107.96.133/login.aspx?ReturnUrl=/my/default.aspx");
}
private void timer1_Tick(object sender, EventArgs e)
{
f();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (i > keshu)
{
timer1.Stop(); //课数学完就不需要学了
timer2.Stop();
}
else
{
play();
}
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//程序加载完毕后将焦点定位到webBrowser1控件,选中开始按钮并执行
this.webBrowser1.Select();
this.webBrowser1.Focus();
SendKeys.SendWait("{TAB}");
SendKeys.SendWait("{ENTER}");
}
}
}