Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterDreeeam committed Apr 7, 2023
1 parent 9f992b5 commit e500e66
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 24 deletions.
18 changes: 0 additions & 18 deletions WinTesterSdk/platform/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,4 @@ void platform::Test(point p)

}

vector<string> platform::Consoles()
{
guard __g(Mutex("_consoles"));
return I()->_consoles;
}

void platform::Console(const string& c)
{
guard __g(Mutex("_consoles"));
return I()->_consoles.push_back(c);
}

void platform::ClearConsole()
{
guard __g(Mutex("_consoles"));
return I()->_consoles.clear();
}

}
6 changes: 0 additions & 6 deletions WinTesterSdk/platform/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ class platform : public xref<platform>

static void Test(point p);

static vector<string> Consoles();

static void Console(const string& c);

static void ClearConsole();

private:
static BOOL CALLBACK _EnumWindowsCb(HWND wnd, LPARAM par);

Expand Down
97 changes: 97 additions & 0 deletions WinTesterSdk/platform/platform_v1.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#pragma once

#include "common.hpp"
#include "area.hpp"
#include "identifier.hpp"
#include "element_stack.hpp"

namespace slim
{

class element;
class element_chain;
class action;

struct TreeElementProxy
{
shared_ptr<slim::element> elm;
int parent;
int dialogs;
};

class platform : public xref<platform>
{
friend class element;

platform();

public:
static shared_ptr<platform> Instance()
{
return _ins ? _ins : (_ins = shared_ptr<platform>(new platform()));
}

static shared_ptr<platform> I()
{
return Instance();
}

static void Release() { _ins = nullptr; }

~platform();

static mutex& Mutex(const string& name);

static WndInfo GetWndInfo(HWND wnd);

static WndInfo GetCurrentWndInfo();

static void UpdateDesktopWnds();

static bool UpdateDesktopWnds(const WndInfo& wndInfo);

static vector<WndInfo> GetWnds();

static vector<WndInfo> GetWnds(const WndInfo& info);

static shared_ptr<element_chain> GetElementChainInActiveWindow(point p, bool fast);

static shared_ptr<element_chain> GetElementChainInDesktop(point p, bool fast);

static shared_ptr<element_matched> FindElementInWindow(WndInfo& wnd, const vector<element_stack>& ess);

static shared_ptr<element_matched> FindElementInDesktop(const vector<element_stack>& ess);

static void Test(point p);

static vector<string> Consoles();

static void Console(const string& c);

static void ClearConsole();

private:
static BOOL CALLBACK _EnumWindowsCb(HWND wnd, LPARAM par);

static void _PermuteElementTree(vector<TreeElementProxy>& candidates, point p, bool fast);

static void _GetElementStacks(shared_ptr<element> root, point p, bool fast, vector<shared_ptr<element>>& ve);

static shared_ptr<element_matched> _FindElement(shared_ptr<element> self, const element_searching& searching);

private:
static shared_ptr<platform> _ins;

private:
IUIAutomation* _uia;
IUIAutomationCondition* _con;
IUIAutomationCacheRequest* _request;

map<string, mutex*> _mtxs;
map<string, vector<WndInfo>> _desktop_wnds; // class name : vInfo
vector<string> _consoles;
};

__declspec(selectany) shared_ptr<platform> platform::_ins = nullptr;

}

0 comments on commit e500e66

Please sign in to comment.