C模拟打开浏览器百度搜索词条单击结束浏览器进程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zgahlibin/article/details/78300291
#include<stdlib.h>
#include<stdio.h>
#include<Windows.h>


void openBaidu() {


ShellExecuteA(0, "open", "http://baidu.com", 0, 0, 3);
}


void pointChar(int i){


keybd_event(i, 0, 0, 0);
keybd_event(i, 0, 2, 0);
}


void search(char str[]) {


//TODO 需要用数组循环来完善
pointChar('X');
pointChar('I');
pointChar('A');
pointChar('N');
pointChar('H');
pointChar('U');
pointChar('A');
pointChar(13);
pointChar(13);
}


void closeBaidu() {


system("taskkill /f /im chrome.exe");
//keybd_event(0x5b, 0, 0, 0);
//keybd_event('E', 0, 0, 0);
////Sleep(10);
//keybd_event(0x5b, 0, 0x2, 0);
//keybd_event('E', 0, 0x2, 0);
}


void click() {

// (300, 300);
SetCursorPos(300, 250);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);


}


void main() {


while (true){


openBaidu();
Sleep(2000);
search("xianhua");
Sleep(4000);
click();
Sleep(2000);
closeBaidu();
Sleep(2000);
}


}

猜你喜欢

转载自blog.csdn.net/zgahlibin/article/details/78300291