命令行内容的获取

    我的命令行控制台由于使用可交互的方法实现,没有使用数据管道的方法,我是通过顶层菜单的复制与粘贴的办法获取的。
int CToolAdb::SetScnCopyInfo()
{
CWnd* pDesktopWnd ;
CWnd* pWnd ;
CString strClassName , strWindowText, strMenuText  ;
CMenu* pMenu ;
CMenu* pMenuSub ;
int nRtn = 0 ;
int nCount ,subCount, id;  
int isFindSelect = 0 ;
int isFindCopy = 0 ;


pDesktopWnd = CWnd::GetDesktopWindow(); 
pWnd = pDesktopWnd->GetWindow( GW_CHILD );
while( pWnd != NULL )
{
//获得窗口类名
::GetClassName(pWnd->GetSafeHwnd(),strClassName.GetBuffer(256),256);


//获得窗口标题
::GetWindowText(pWnd->GetSafeHwnd(),strWindowText.GetBuffer(256),256);


if(  strWindowText.Find( m_strTilte ) >= 0 )
{
nRtn = 1 ;
pMenu = pWnd->GetSystemMenu(FALSE);
nCount = pMenu->GetMenuItemCount(); 
for(int i = 0 ; i < nCount;i++)  
{
id = pMenu->GetMenuItemID( i );  
nRtn = pMenu->GetMenuString( i , strMenuText , MF_BYPOSITION );  
//遍历子菜单
if ( id== -1 )
{
pMenuSub = pMenu->GetSubMenu( i ) ;
subCount = pMenuSub->GetMenuItemCount();  
for( int j = 0 ;j < subCount ;j ++ )
{
id = pMenuSub->GetMenuItemID( j );  
nRtn = pMenuSub->GetMenuString( j , strMenuText , MF_BYPOSITION ); 


if( strMenuText.Find( "全选") >= 0 )
{
isFindSelect = 1 ;
::PostMessage( pWnd->GetSafeHwnd() , WM_COMMAND, id , 0);
break ;
}
}
Sleep( 300 ) ;
if( isFindSelect == 1 )
for( int j = 0 ;j < subCount ;j ++ )
{
id = pMenuSub->GetMenuItemID( j );  
nRtn = pMenuSub->GetMenuString( j , strMenuText , MF_BYPOSITION ); 


if( strMenuText.Find( "复制") >= 0 )
{
isFindCopy = 1 ;
::PostMessage( pWnd->GetSafeHwnd() , WM_COMMAND, id , 0);
break ;
}
}


if( isFindSelect ==1 && isFindCopy == 1 )
break ;


}//if ( id== -1 )
}//for(int i = 0 ; i < nCount;i++)  
break ;
}


//继续下一个子窗口
pWnd = pWnd->GetWindow(GW_HWNDNEXT);
}

if( isFindSelect ==1 && isFindCopy == 1 )
nRtn = 1 ;

Sleep( 300 ) ;
return nRtn ;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值