• 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);
    }
    }

      

  • 相关阅读:
    Linux下如何查看版本信息
    java单利模式设计
    MIT 2012 分布式课程基础源码解析-底层通讯实现
    MIT 2012分布式课程基础源码解析-事件管理封装
    MIT 2012分布式课程基础源码解析-线程池实现
    MIT 2012分布式课程基础源码解析一-源码概述
    Leetcode按Tag刷题
    网页搜集系统
    c/c++中的各种字符串转换
    gentoo装X服务器时显卡选择
  • 原文地址:https://www.cnblogs.com/carl2380/p/2290412.html
Copyright © 2020-2023  润新知