mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-12 04:11:06 -05:00
Add window action
It allows to set the focus window and close windows. Only supported on Windows for now.
This commit is contained in:
@@ -204,6 +204,45 @@ std::string GetWindowClassByWindowTitle(const std::string &window)
|
||||
return className;
|
||||
}
|
||||
|
||||
void SetFocusWindow(const std::string &title)
|
||||
{
|
||||
auto handle = getHWNDfromTitle(title);
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
ShowWindow(handle, SW_RESTORE);
|
||||
SetForegroundWindow(handle);
|
||||
SetFocus(handle);
|
||||
SetActiveWindow(handle);
|
||||
}
|
||||
|
||||
void CloseWindow(const std::string &title)
|
||||
{
|
||||
auto handle = getHWNDfromTitle(title);
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
SendMessage(handle, WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
||||
void MaximizeWindow(const std::string &title)
|
||||
{
|
||||
auto handle = getHWNDfromTitle(title);
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
ShowWindow(handle, SW_MAXIMIZE);
|
||||
}
|
||||
|
||||
void MinimizeWindow(const std::string &title)
|
||||
{
|
||||
auto handle = getHWNDfromTitle(title);
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
ShowWindow(handle, SW_MINIMIZE);
|
||||
}
|
||||
|
||||
class RawMouseInputFilter;
|
||||
static RawMouseInputFilter *mouseInputFilter;
|
||||
static std::chrono::high_resolution_clock::time_point lastMouseLeftClickTime{};
|
||||
|
||||
Reference in New Issue
Block a user