Ejemplo n.º 1
0
int LuaWin32Shell::GetIEMainPage(lua_State* luaState)
{
	CRegKey reg;
	if (reg.Open(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main") == ERROR_SUCCESS)
	{
		wchar_t strUrl[1024] = {0};
		ULONG ulSize = 1024;
		if (reg.QueryStringValue(L"Start Page", strUrl, &ulSize) == ERROR_SUCCESS)
		{
			std::string utf8Url;
			Unicode_to_UTF8(strUrl, ::wcslen(strUrl), utf8Url);
			lua_pushstring(luaState, utf8Url.c_str());
			return 1;
		}
	}

	lua_pushnil(luaState);
	return 1;
}
Ejemplo n.º 2
0
bool CTaoBaoTask::checkElementByText( std::string idValue,TiXmlElement *root )
{
	int outLen=0;
	std::string s_bounds;
	TiXmlString s1;
	int pos = 0;//name(//*[@resource-id=' '])
	s_bounds = ("name(//*[@text='");
	s_bounds +=	idValue;
	s_bounds += ("'])");
	std::wstring tmpWstr;
	ANSI_to_Unicode(s_bounds.c_str(),s_bounds.length(),tmpWstr);
	Unicode_to_UTF8(tmpWstr.c_str(),tmpWstr.length(),s_bounds);
	s1 = TinyXPath::S_xpath_string(root,s_bounds.c_str());
	s_bounds = s1.c_str();
	if (s_bounds.empty()||s_bounds.length()==0 ||s_bounds.find(("node"))==-1)
	{
		return false;
	}
	return true;

}
Ejemplo n.º 3
0
std::string CTaoBaoTask::getTextById( std::string idValue,TiXmlElement *root )
{
	std::wstring wRet;
	int outLen=0;
	std::string s_bounds;
	TiXmlString s1;
	int pos = 0;//name(//*[@resource-id=' '])
	s_bounds = ("//*[@resource-id='");
	s_bounds +=	idValue;
	s_bounds += ("']/@text");
	std::wstring tmpWstr;
	ANSI_to_Unicode(s_bounds.c_str(),s_bounds.length(),tmpWstr);
	Unicode_to_UTF8(tmpWstr.c_str(),tmpWstr.length(),s_bounds);
	s1 = TinyXPath::S_xpath_string(root,s_bounds.c_str());
	s_bounds = s1.c_str();
	UTF8_to_Unicode(s_bounds.c_str(),s_bounds.length(),wRet);
	Unicode_to_ANSI(wRet.c_str(),wRet.length(),s_bounds);

	printLog("==getTextById== idValue = %s\n",idValue.c_str());
	printLog("==getTextById== Result  = %s\n",s_bounds.c_str());

	return s_bounds;

}
Ejemplo n.º 4
0
void CTaoBaoTask::getBoundsByText( std::string idValue,TiXmlElement *root,int* ileft,int* itop,int* iright,int *ibottom )
{
	int outLen = 0;
	std::string left ;
	std::string top ;
	std::string right ;
	std::string bottom ;
	std::string s_bounds;
	TiXmlString s1;
	int pos = 0;
	s_bounds = ("//*[@text='");
	s_bounds +=	idValue;
	s_bounds += ("']/@bounds");
	std::wstring tmpWstr;
	ANSI_to_Unicode(s_bounds.c_str(),s_bounds.length(),tmpWstr);
	Unicode_to_UTF8(tmpWstr.c_str(),tmpWstr.length(),s_bounds);
	s1 = TinyXPath::S_xpath_string(root,s_bounds.c_str());
	if (s1.empty()||s1.length()==0)
	{
		return ;
	}
	s_bounds = s1.c_str();

	pos = s_bounds.find_first_of(("0123456789"));
	if (pos == -1)
	{
		return ;
	}
	s_bounds = s_bounds.substr(pos);
	pos = s_bounds.find_first_of(("[], "));
	if (pos == -1)
	{
		return ;
	}
	left = s_bounds.substr(0, pos);

	s_bounds = s_bounds.substr(pos);
	pos = s_bounds.find_first_of(("0123456789"));
	if (pos == -1)
	{
		return ;
	}
	s_bounds = s_bounds.substr(pos);
	pos = s_bounds.find_first_of(("[], "));
	if (pos == -1)
	{
		return ;
	}
	top = s_bounds.substr(0, pos);

	s_bounds = s_bounds.substr(pos);
	pos = s_bounds.find_first_of(("0123456789"));
	if (pos == -1)
	{
		return ;
	}
	s_bounds = s_bounds.substr(pos);
	pos = s_bounds.find_first_of(("[], "));
	if (pos == -1)
	{
		return ;
	}
	right = s_bounds.substr(0, pos);

	s_bounds = s_bounds.substr(pos);
	pos = s_bounds.find_first_of(("0123456789"));
	if (pos == -1)
	{
		return ;
	}
	s_bounds = s_bounds.substr(pos);
	pos = s_bounds.find_first_of(("[], "));
	if (pos == -1)
	{
		return ;
	}
	bottom = s_bounds.substr(0, pos);
	*ileft = atoi(left.c_str())+1;
	*itop = atoi(top.c_str())+1;
	*iright = atoi(right.c_str());
	*ibottom = atoi(bottom.c_str());
	return ;
}