1 #define _CRT_SECURE_NO_WARNINGS 2 3 #include<stdio.h> 4 #include<stdlib.h> 5 #include<windows.h> 6 7 void openbaidu() 8 { 9 ShellExecuteA(0, "open", "https://www.baidu.com/s?wd=%E5%A4%A9%E6%B4%A5%E7%8E%9B%E4%B8%BD%E5%8C%BB%E9%99%A2&rsv_spt=1&rsv_iqid=0xfa691c82003cd1bb&issp=1&f=8&rsv_bp=0&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=1&rsv_n=2&rsv_sug3=1", 0, 0, 0); 10 /* 打开网页 */ 11 } 12 13 void closebaidu() 14 { 15 system("taskkill /f /im iexplore.exe"); /* 结束进程 */ 16 } 17 18 void clickbaidu() 19 { 20 SetCursorPos(200,300); /* 把光标移到屏幕的指定位置 */ 21 Sleep(5000); /* 功能: 执行挂起一段时间 */ 22 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); /* 表明松开鼠标左键。 */ 23 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); /* 表明接按下鼠标左键。 */ 24 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); 25 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); 26 } 27 28 main() 29 { 30 while (1) 31 { 32 openbaidu(); 33 34 Sleep(5000); 35 36 clickbaidu(); 37 38 Sleep(5000); 39 40 closebaidu(); 41 42 Sleep(1000); 43 } 44 }
时间: 2024-10-16 03:24:37