wincc吧 关注:2,649贴子:6,297
  • 0回复贴,共1

大佬们,我有一段代码想写在C脚本中,求大神帮忙

只看楼主收藏回复

#define _WIN32_WINNT 0x0500
#define WINVER 0x0500 //GetLastInputInfo needs Win2K
#include <windows.h>
#include <iostream>
int start,m,end;
void test(int s)
{
start=::GetTickCount();
LASTINPUTINFO lpi;
lpi.cbSize=sizeof(lpi);
while(true){
m=::GetTickCount();
GetLastInputInfo(&lpi); //开始获取键盘鼠标空闲状态的时间
if(::GetTickCount()-lpi.dwTime>1000*s){ //当超过n*s毫秒没有操作时,执行打印输出,跳出死循环
printf("已经");
printf("%d",s);
printf("%s\n","秒没有操作,将停止循环!");
end=::GetTickCount();
break;
}else{printf("%s\n","Duang!!!");}
}
printf("%d\n",m-start);
printf("%d\n",end-start);
}
void main()
{
int t;
scanf("%d",&t);
test(t);
// return 0;
}


IP属地:湖南1楼2017-03-27 17:26回复