您的位置:首页 > 其它

wifi+定时关机1.0

2016-12-30 23:04 106 查看
#include "cv.h"
#include "highgui.h"

#include <iostream>
#include "windows.h"
#include <iostream>
#include <string>
#include <sstream>
#include <stdlib.h>
using namespace std;

void print()
{
system( "mode con cols=59 lines=25" );//窗口宽度高度
system( "color 8f" );
//SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN);
//printf("Hello");
system( "CLS" );
system( "title All Copyright Reserved by Author of ims" );//设置cmd窗口标题
cout    << " ╔══════════════════════════╗\n"
<< " ║                  按序号执行任务                    ║\n"
<< " ║══════════════════════════║\n"
<< " ║        WIFI             ║      关机               ║\n"
<< " ║  1.启用无线网络         ║  11.延时关机(单位分钟)║\n"
<< " ║  2.停止无线网络         ║  12.取消延时关机任务    ║\n"
<< " ║  3.显示连接用户         ║  13.定时关机            ║\n"
<< " ║  4.显示WiFi密码         ║  14.取消延时关机任务    ║\n"
<< " ║  5.修改WiFi名称         ║  15.查看计划            ║\n"
<< " ║  6.修改WiFi密码         ║  16.退出                ║\n"
<< " ║  7.首次使用初始化       ║  17.使用说明            ║\n"
<< " ║══════════════════════════║\n"
<< " ║  10.启用摄像头                                     ║\n"
<< " ╚══════════════════════════╝\n";
}
int main()
{
print();
string c;
cout<<"输入任务序号:";
cin >> c;
while( c != "0" )
{
while( c == "10" )
{
cvNamedWindow("Camera");
CvCapture* capture = cvCreateCameraCapture(0);    //创建并获取摄像设备
IplImage* frame;
while(1)
{
frame = cvQueryFrame(capture);    //创建并获取一张摄像截图
if(!frame) break;        //如果失败终止循环
cvShowImage("Camera", frame);    //在一个"win"窗口,并当中显示该截图
int c = cvWaitKey(15);//等待50ms
if(c>0) //对应esc键值
break;
}
cvReleaseCapture(&capture);        //释放摄像设备
cvDestroyWindow("Camera");        //释放窗口"win"
goto loop;
}
loop:
while( c == "11" )
{
string down="shutdown -s -t ";
int t;
cout<<"输入延时关机时间:";
cin>>t;
stringstream s;
s<<t;
t*=60;
stringstream ss;
ss<<t;
string input;
ss>>input;
down+=input;
const char *shut=down.c_str();
//cout<<shut<<endl;
system(shut);
string out="分钟后关机。 ";
string s1;
s>>s1;
s1+=out;
cout<<s1<<endl;
cout<<endl;
break;

}
while( c == "12" )
{
system( "shutdown -a" );
cout<<"关机任务已经取消。"<<endl;
break;
}
while( c == "13" )
{
stringstream ss1,ss2;
string down="at ";
string str=" shutdown -s -t 10";
int t1,t2;
string st1,st2;
cout<<"输入定时关机时间:";
cin>>t1;
cin>>t2;
if(t1>23||t1<0||t2<0||t2>59)
{
cout<<"输入正确的24小时制的时间,时与分之间用空格分割。"<<endl;
continue;
}
ss1<<t1;
ss1>>st1;
ss2<<t2;
ss2>>st2;
down+=st1;
down+=":";
down+=st2;
down+=str;
const char *shut=down.c_str();
//cout<<shut<<endl;
system(shut);
break;
//system( "time" );
}
while( c == "14" )
{
system( "at /delete" );
break;
}
while( c == "15" )
{
system( "at" );
break;
}

while( c == "16" )
{
return 0;
}

while( c == "1" )
{
system( "netsh wlan start hostednetwork" );
break;
}
while( c == "2" )
{
system( "netsh wlan stop hostednetwork" );
break;
}
while( c == "3" )
{
system( "netsh wlan show hostednetwork" );
break;
}
while( c == "4" )
{
system( "netsh wlan show hostednetwork security" );
break;
}
while( c == "5" )
{
string str="netsh wlan set hostednetwork ssid= ";
string str1;
cout<<"输入新wifi名:";
cin>>str1;
str+=str1;
const char *cmd=str.c_str();
system(cmd );
break;
}
while( c == "6" )
{
string str="netsh wlan set hostednetwork key= ";
string str1;
cout<<"输入新密码:";
cin>>str1;
str+=str1;
const char *cmd=str.c_str();
system( cmd );
break;
}
while( c == "7" )
{
system( "netsh wlan set hostednetwork mode=allow ssid=default_wifi key=12345678" );
break;
}
while( c == "17" )
{
cout<<"wifi:首次使用时,把本地连接设置为共享。";
break;
}
cout<<endl;
cout<<"输入任务序号:";
cin >> c;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: