很简单// 鼠标键盘.cpp : Defines the entry point for the console application.//#include stdafx.h#include windows.hvoid creatqq(){STARTUPINFO si = {0}; PROCESS_INFORMATION pi; ...
很简单
// 鼠标键盘.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <windows.h> void creatqq() { STARTUPINFO si = {0}; PROCESS_INFORMATION pi; si.cb = sizeof(si); TCHAR qqname[]=TEXT("C:/Users/CSXJJ/Desktop/2.exe"); BOOL res = CreateProcess( qqname, NULL, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi); if (res==NULL) { MessageBox(NULL,TEXT("进程创建失败"),0,0); } Sleep(1000); } int main(int argc, char* argv[]) { creatqq(); HWND hwnd=::FindWindow(TEXT("WTWindow"),TEXT("")); if(hwnd != NULL) { //修改窗口标题 ::SetWindowText(hwnd,"新的窗口标题"); } else { ::MessageBox(NULL,TEXT("窗口没有找到"),TEXT("[ERROR]"),MB_OK); } HWND htext = FindWindowEx(hwnd,NULL,"Edit","");//获取子窗口 用ex函数 //printf("%d",htext); //模拟鼠标单击 RECT r; //获得编辑框输出的矩形区域 ::GetWindowRect(htext,&r); ::SetCursorPos(r.left+10,r.top+10); //printf("%d",r.left+10); //鼠标左键单击 mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//点下左键 mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);//松开左键 //模拟键盘 keybd_event(97,0,0,0); keybd_event(97,0,KEYEVENTF_KEYUP,0); Sleep(1000); keybd_event(66,0,0,0); keybd_event(66,0,KEYEVENTF_KEYUP,0); ::SendMessage(htext,WM_SETTEXT,NULL,(LPARAM)"4756");;//设置文字 Sleep(1000); ::SendMessage(hwnd,WM_CLOSE,NULL,NULL); return 0; }
参照代码
沃梦达教程
本文标题为:c++ 创建进程设置窗口标题模拟键盘鼠标例子
基础教程推荐
猜你喜欢
- C/C++编程中const的使用详解 2023-03-26
- 详解c# Emit技术 2023-03-25
- C利用语言实现数据结构之队列 2022-11-22
- C语言基础全局变量与局部变量教程详解 2022-12-31
- 如何C++使用模板特化功能 2023-03-05
- C++中的atoi 函数简介 2023-01-05
- C语言 structural body结构体详解用法 2022-12-06
- C++使用easyX库实现三星环绕效果流程详解 2023-06-26
- 一文带你了解C++中的字符替换方法 2023-07-20
- C++详细实现完整图书管理功能 2023-04-04