当前位置: 首页>>代码示例>>C++>>正文


C++ WindowManager::GetImage方法代码示例

本文整理汇总了C++中WindowManager::GetImage方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowManager::GetImage方法的具体用法?C++ WindowManager::GetImage怎么用?C++ WindowManager::GetImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WindowManager的用法示例。


在下文中一共展示了WindowManager::GetImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	//is auto?
	bool autoMove = true;
	GetCursorPos(&lastMouse);

	//object
	WindowManager* window = new WindowManager();
	Forager bot = Forager();
	MouseManager mouse = MouseManager(0);

	//non-object
	int* board = new int[BOARD_WIDTH * BOARD_HEIGHT];


	//----------------------------------------------------------------------


	printf("Welcome to OpenForager, a free open-source puzzle solving bot!\n\n");

searchPoint:
	//search for the YPP window
	printf("Searching for YPP window..,\n");
	while (!window->WindowFound())
	{
		window->FindWindow();
	}

	//at this point we have found the window
	while (window->WindowExists())
	{
		while (window->WindowFocused())
		{
			//create image
			BYTE* image = window->GetImage();

			while (window->PuzzleFound(image))
			{
				//read board in
				PuzzleBoard::ReadBoard(image, board);

				//solve puzzle
				std::vector<Vector2*> moves = bot.Solve(board);
				Vector2* move = nullptr;
				//if (move != nullptr)
				//	delete move;

				if (autoMove)
				{
					while (!moves.empty())
					{
						move = moves.back();
						moves.pop_back();

						if (move != nullptr)
						{
							POINT currentMouse;
							GetCursorPos(&currentMouse);

							if (currentMouse.x == lastMouse.x && currentMouse.y == lastMouse.y)
							{
								printf("trying to move\n");

								//make moves
								Vector2* pos = window->GetWindowPosition();
								pos->x += BOARD_X + (move->x * 45) + 22;
								pos->y += BOARD_Y + (move->y * 45) + 22;

								mouse.ExecuteMovementTo(window, *pos, 25);

								if (move->left)
									mouse.ExecuteLeftClick();
								else
									mouse.ExecuteRightClick();
							}

							GetCursorPos(&lastMouse);

							delete move;

							Sleep(100 + MouseManager::RandomRange(0, 500));
						}
					}
				}

				delete [] image;
				image = window->GetImage();
			}
		}
	}

	window->ResetWindow();
	goto searchPoint;

	return 0;
}
开发者ID:pixelgriffin,项目名称:OpenForager,代码行数:96,代码来源:main.cpp


注:本文中的WindowManager::GetImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。