mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Add option to get window class of window
This commit is contained in:
parent
cde4e24cc4
commit
50c54a8341
|
|
@ -1502,7 +1502,9 @@ AdvSceneSwitcher.tempVar.scene.previous="Previous scene"
|
|||
AdvSceneSwitcher.tempVar.scene.preview="Preview scene"
|
||||
|
||||
AdvSceneSwitcher.tempVar.window.window="Window title"
|
||||
AdvSceneSwitcher.tempVar.window.window.description="The window title of the current foreground window."
|
||||
AdvSceneSwitcher.tempVar.window.window.description="The window title of the matching window."
|
||||
AdvSceneSwitcher.tempVar.window.windowClass="Window class"
|
||||
AdvSceneSwitcher.tempVar.window.windowClass.description="The window class of the matching window."
|
||||
|
||||
AdvSceneSwitcher.tempVar.timer.seconds="Seconds"
|
||||
AdvSceneSwitcher.tempVar.timer.minutes="Minutes"
|
||||
|
|
|
|||
|
|
@ -87,6 +87,10 @@ void MacroConditionWindow::SetVariableValueBasedOnMatch(
|
|||
const std::string &matchWindow)
|
||||
{
|
||||
SetTempVarValue("window", matchWindow);
|
||||
#ifdef _WIN32
|
||||
SetTempVarValue("windowClass",
|
||||
GetWindowClassByWindowTitle(matchWindow));
|
||||
#endif
|
||||
if (!IsReferencedInVars()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -172,6 +176,13 @@ void MacroConditionWindow::SetupTempVars()
|
|||
obs_module_text("AdvSceneSwitcher.tempVar.window.window"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.window.window.description"));
|
||||
#ifdef _WIN32
|
||||
AddTempvar(
|
||||
"windowClass",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.window.windowClass"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.window.windowClass.description"));
|
||||
#endif
|
||||
}
|
||||
|
||||
MacroConditionWindowEdit::MacroConditionWindowEdit(
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ extern std::chrono::high_resolution_clock::time_point lastMouseRightClickTime;
|
|||
void GetWindowList(std::vector<std::string> &windows);
|
||||
void GetWindowList(QStringList &windows);
|
||||
void GetCurrentWindowTitle(std::string &title);
|
||||
#ifdef _WIN32
|
||||
std::string GetWindowClassByWindowTitle(const std::string &window);
|
||||
#endif
|
||||
bool IsFullscreen(const std::string &title);
|
||||
bool IsMaximized(const std::string &title);
|
||||
std::optional<std::string> GetTextInWindow(const std::string &window);
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ void GetCurrentWindowTitle(std::string &title)
|
|||
GetWindowTitle(window, title);
|
||||
}
|
||||
|
||||
static HWND getHWNDfromTitle(std::string title)
|
||||
static HWND getHWNDfromTitle(const std::string &title)
|
||||
{
|
||||
HWND hwnd = NULL;
|
||||
wchar_t wTitle[512];
|
||||
|
|
@ -211,6 +211,26 @@ static HWND getHWNDfromTitle(std::string title)
|
|||
return hwnd;
|
||||
}
|
||||
|
||||
std::string GetWindowClassByWindowTitle(const std::string &window)
|
||||
{
|
||||
HWND hwnd = NULL;
|
||||
hwnd = getHWNDfromTitle(window);
|
||||
if (!hwnd) {
|
||||
return "";
|
||||
}
|
||||
std::wstring wClass;
|
||||
wClass.resize(1024);
|
||||
if (!GetClassNameW(hwnd, &wClass[0], wClass.capacity())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t len = os_wcs_to_utf8(wClass.c_str(), 0, nullptr, 0);
|
||||
std::string className;
|
||||
className.resize(len);
|
||||
os_wcs_to_utf8(wClass.c_str(), 0, &className[0], len + 1);
|
||||
return className;
|
||||
}
|
||||
|
||||
bool IsMaximized(const std::string &title)
|
||||
{
|
||||
RECT appBounds;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user