#include.h>
#include.h>
#include.h>
#pragma comment(lib, "shell32.lib")
//同步
//void openwapj()
//{
// system("\"F:\\Program Files (x86)\\360Chrome\\Chrome\\Application\\360chrome.exe\" http://www.52pojie.cn/portal.php");
//
//}
//异步
void baidu()
{
ShellExecuteA(0, "open", "https://www.baidu.com/",0,0,0);
}
void close()
{
system("taskkill /f /im 360se.exe");
}
void search()
{
keybd_event(68, 0, 0, 0);
keybd_event(68, 0, 2, 0);
Sleep(20);
keybd_event(65, 0, 0, 0);
keybd_event(65, 0, 2, 0);
Sleep(20);
keybd_event(78, 0, 0, 0);
keybd_event(78, 0, 2, 0);
Sleep(20);
keybd_event(69, 0, 0, 0);
keybd_event(69, 0, 2, 0);
Sleep(20);
keybd_event(73, 0, 0, 0);
keybd_event(73, 0, 2, 0);
Sleep(20);
keybd_event(0X20, 0, 0, 0);
keybd_event(0X20, 0, 2, 0);
Sleep(20);
keybd_event(0X0D, 0, 0, 0);
keybd_event(0X0D, 0, 2, 0);
Sleep(20);
}
void click()
{
SetCursorPos(300, 420);
Sleep(20);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Sleep(20);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
void main()
{
//HWND win;
//win = FindWindowA("ConsoleWindowClass", NULL);
//ShowWindow(win,SW_HIDE);//隐藏控制台窗口
while (1)
{
Sleep(20);
baidu();
Sleep(4000);
search();
Sleep(3000);
click();
Sleep(3000);
close();
}
}
注意:VS中链接库有两种方式:1.项目设置。2.代码设置。