I am trying to select an entry on a list control in another app. to make it look like I just left clicked on that particular list entry.
I am trying this code but it doesn't work, no errors but the result is not what I want.
Code:HWND TargetWindow = ::FindWindow(_T("#32770"),_T("MYAPP")); if(TargetWindow != NULL){ //AfxMessageBox(_T("Found the Window"),MB_OK|MB_ICONSTOP|MB_SETFOREGROUND|MB_TOPMOST); CWnd *ListHandle = FindWindowEx(TargetWindow,NULL,_T("SysListView32"),NULL); if(ListHandle != NULL){ //AfxMessageBox(_T("Found the List Handle"),MB_OK|MB_ICONSTOP|MB_SETFOREGROUND|MB_TOPMOST); LVITEM lvitem; lvitem.mask=LVIF_PARAM|LVIF_STATE; lvitem.iItem=10; lvitem.iSubItem=0; lvitem.state=LVIS_SELECTED|LVIS_FOCUSED; BOOL Success = ListHandle->PostMessage(LVM_SETITEM,0,(LPARAM)&lvitem); if(Success == 0) AfxMessageBox(_T("PostMessage failed"),MB_OK|MB_ICONSTOP|MB_SETFOREGROUND|MB_TOPMOST); } }else{ AfxMessageBox(_T("Could not find the Window"),MB_OK|MB_ICONSTOP|MB_SETFOREGROUND|MB_TOPMOST); }




Reply With Quote