• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
张纯睿
博客园    首页    新随笔    联系   管理    订阅  订阅

RunMessageScript from spy

1、执行函数

void CComputerRobotTestDlg::RunMessageScript(CString str)
{
// <00055> 00020540 S message:0x07F3 [用户定义:WM_USER+1011] wParam:00000000 lParam:00000000
CString sInput = str;
int pos1, pos2;
// get wnd handle
pos1 = sInput.Find(_T("> ")) + _tcslen(_T("> "));;
CString strHWND = sInput.Mid(pos1, _tcslen(_T("00020540")));

pos1 = sInput.Find(_T("> ")) + _tcslen(_T("> 00020540 "));
CString strFun = sInput.Mid(pos1, 1);

pos1 = sInput.Find(_T("message:")) + _tcslen(_T("message:"));
CString strmessage = sInput.Mid(pos1, _tcslen(_T("0x07F3")));

pos1 = sInput.Find(_T("wParam:")) + _tcslen(_T("wParam:"));
CString strwParam = sInput.Mid(pos1, _tcslen(_T("00000000")));

pos1 = sInput.Find(_T("lParam:")) + _tcslen(_T("lParam:"));
CString strlParam = sInput.Mid(pos1, _tcslen(_T("00000000")));

HWND hWnd = NULL;
DWORD dMsg;
WPARAM wParam;
LPARAM lParam;

#ifdef _UNICODE
hWnd = (HWND)wcstoul(strHWND, NULL, 16);
dMsg = (DWORD)wcstoul(strmessage, NULL, 16);
wParam = (WPARAM)wcstoul(strwParam, NULL, 16);
lParam = (LPARAM)wcstoul(strlParam, NULL, 16);
#else
hWnd = (HWND)strtoul(strHWND, NULL, 16);
dMsg = (DWORD)strtoul(strmessage, NULL, 16);
wParam = (WPARAM)strtoul(strlParam, NULL, 16);
lParam = (LPARAM)wcstoul(strlParam, NULL, 16);
#endif

if (_T("S")==strFun)
{
::SendMessage(hWnd, dMsg, wParam, lParam);
}
else if (_T("P")==strmessage)
{
::PostMessage(hWnd, dMsg, wParam, lParam);
}

}

2、调用函数

CStdioFileEx file;
if (file.Open(_T("c:\\tmp.txt"), CFile::modeRead))
{
CString str;
while (file.ReadString(str))
{
RunMessageScript(str);
}
}

  

posted @ 2011-12-16 16:44  张纯睿  阅读(153)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3