C++编写的简单的网页自动刷新器

源代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <ctime>
#include <Windows.h>
using namespace std;
int interval;
int cnt=0;

void delay(const int time){
clock_t now=clock();
while(clock()-now<time);
}
int main(){
SetConsoleTitle("Auto Refresh");
cout<<"注意,在使用本实用程序的时候请把要刷新的网页放在前台,后台无法使用."<<endl;
cout<<"提示:请最好不要在使用这个实用程序的过程中使用别的软件,尤其是以F5为快捷键的软件."<<endl;
cout<<"请输入要刷新网页的延迟时间(单位:毫秒):";
cin>>interval;
for(;;){
delay(interval);
keybd_event(116,0,0,0);
keybd_event(116,0,KEYEVENTF_KEYUP,0);
cnt++;
cout<<"已经刷新了"<<cnt<<"次"<<endl;
}
return 0;
}