16,472
社区成员
发帖
与我相关
我的任务
分享
while (1)
{
Sleep(100);
POINT pt; GetCursorPos(&pt);
hWnd = ::WindowFromPoint(pt);
if (hWnd != NULL)
{
CString strItem = L"精ab瑞cd电脑汉字";
char szItem[] = "精ab瑞cd电脑汉字";
WCHAR wszItem[256];
m_edtInput.SetFocus();
memset(wszItem, 0, sizeof(wszItem));
MultiByteToWideChar(CP_ACP, 0, szItem, strlen(szItem), wszItem, strlen(szItem));
for (int i = 0; i < wcslen(wszItem); i ++)
{
::SendMessage(hWnd, WM_CHAR, wszItem[i], 1);
}
break;
}
else
continue;
}
OnTimer()改为如下
POINT pnt;
RECT rc;
HWND DeskHwnd = ::GetDesktopWindow(); //取得桌面句柄
HDC DeskDC = ::GetWindowDC(DeskHwnd); //取得桌面设备场景
int oldRop2 = SetROP2(DeskDC, R2_NOTXORPEN);
::GetCursorPos(&pnt); //取得鼠标坐标
HWND UnHwnd = ::WindowFromPoint(pnt) ; //取得鼠标指针处窗口句柄
g_hWnd=UnHwnd;
HWND grayHwnd = ::GetWindow(g_hWnd, GW_CHILD);
RECT tempRc;
BOOL bFind=FALSE;
while (grayHwnd)
{
::GetWindowRect(grayHwnd, &tempRc);
if(::PtInRect(&tempRc,pnt))
{
bFind = TRUE;
break;
}
else
grayHwnd = ::GetWindow(grayHwnd, GW_HWNDNEXT);
}//while
if(bFind == TRUE)
{
bFind= FALSE;
g_hWnd = grayHwnd;
}
else
;//Wnd=UnHwnd
POINT pt;
::GetCursorPos(&pt);
POINT ptScreen=pt;
m_hParent=GetDesktopWindow()->GetSafeHwnd();
m_hChild=::ChildWindowFromPoint(m_hParent,pt);
pt=ptScreen;
::ScreenToClient(m_hChild,&pt);
while(m_hParent != m_hChild)
{
m_hParent=m_hChild;
m_hChild=::ChildWindowFromPoint(m_hParent,pt);
pt=ptScreen;
::ScreenToClient(m_hChild,&pt);
}
CString strItem = L"精ab瑞cd电脑汉字";
char szItem[] = "精ab瑞cd电脑汉字";
WCHAR wszItem[256];
m_edtInput.SetFocus();
memset(wszItem, 0, sizeof(wszItem));
MultiByteToWideChar(CP_ACP, 0, szItem, strlen(szItem), wszItem, strlen(szItem));
if(m_hChild != NULL)
{
for (int i = 0; i < wcslen(wszItem); i ++)
{
::SendMessage(m_hChild, WM_CHAR, wszItem[i], 1);
}
}