问题描述
- 为什么我截图发送给一个答题接口,获得返回值之后传给游戏程序 取不到值。谢谢各位了
- static BOOL SyncGetAnswer(LPCSTR szJpgFile LPCSTR& szAnswer)
{
BOOL bResult = FALSE;
HMODULE hMod = NULL;
TRYBLOCK_START
CHAR szPath[MAX_PATH] = {0};
// 发送答题
wsprintfA(szPath%slldm.dll"" GetAppPath(GAME_REG_APPPATH));
if (!(hMod = LoadLibraryA(szPath)))
{
OutputDebugInfo(""Load lldm.dll error: %d"" GetLastError());
return FALSE;
}CHAR szAuthcode[256] = {0};wsprintfA(szPath%s\游戏设置.ini"" GetAppPath(GAME_REG_APPPATH));GetPrivateProfileStringA(""游戏设置""答题串码""" szAuthcode sizeof(szAuthcode) szPath);if (!szAuthcode[0]) strcpy(szAuthcodetpgwb7r77uDzhDfb"");OutputDebugInfo(""答题串码: %s"" szAuthcode);FUNC_SendFile SendFile = (FUNC_SendFile)(GetProcAddress(hModSendFile""));LPCSTR szId = SendFile(szAuthcode szJpgFile 5002 30 1");if (szId[0] == '#'){ OutputDebugInfo(""上传验证码失败: %s"" szId); FreeLibrary(hMod); return FALSE;}// 接收答案FUNC_GetAnswer GetAnswer = (FUNC_GetAnswer)(GetProcAddress(hModGetAnswer""));Sleep(3000);for (int i=0; i<28; i++){ szAnswer = GetAnswer(szId); if (szAnswer && szAnswer[0]) break; Sleep(1000);}if (!szAnswer || !szAnswer[0]) OutputDebugInfo(""Get answer timeout"");else if (szAnswer[0] == '#') OutputDebugInfo(""获取验证码识别结果出错: %s"" szAnswer);else bResult = TRUE;TRYBLOCK_ENDFreeLibrary(hMod);return bResult;
}
static BOOL ChooseAnswer(LPCSTR szAnswer)
{
switch (szAnswer[0])
{
case '1':
CGameCall::FightChooseOption(""A"");
break;
case '2':
CGameCall::FightChooseOption(""B"");
break;
case '3':
CGameCall::FightChooseOption(""C"");
break;
case '4':
CGameCall::FightChooseOption(""D"");
break;
case '5':
CGameCall::FightChooseOption(""E"");
break;
default:
return FALSE;
}
return TRUE;
}static BOOL CaptrueAndAnswer(VOID)
{
CImage image;
// 窗口截图
RECT rect = {220 120 620 480};
if (!CaptureWindow(CGameWind::Instance().GetHandle() rect image))
return FALSE;// 添加文本if (!AddTextInfo(image)) return FALSE;// 保存文件CHAR szJpgFile[MAX_PATH] = {0};wsprintfA(szJpgFile%s\%d.jpg"" GetAppPath(GAME_REG_APPPATH) GetCurrentProcessId());DeleteFileA(szJpgFile);image.Save(szJpgFile Gdiplus::ImageFormatJPEG);// 发送答题LPCSTR szAnswer = NULL;if (!SyncGetAnswer(szJpgFile szAnswer)){ return FALSE;}else { OutputDebugInfo(""Answer: %s"" szAnswer); return ChooseAnswer(szAnswer);}
}
时间: 2024-10-28 11:58:28