var hdWin,hdfocus: THandle;
trdID: Cardinal;
//获取前置app窗口句柄
hdWin := GetForegroundWindow;//FindWindow(nil,'Project1');
//获取前置app线程句柄
trdID := GetWindowThreadProcessId(hdWin,nil);
//连接当前线程与前置线程,消息将有当前进行处理
AttachThreadInput(trdID,GetCurrentThreadId,True);
hdFocus := windows.GetFocus;
//{ *** 作代码}
Windows.SetFocus(hdWin);
PostMessage(hdFocus,WM_CHAR,ord('A'),0);
//解除线程连接
AttachThreadInput(trdID,GetCurrentThreadId,False);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)