Author |
Topic |
|
Orcus
11 Posts |
Posted - 10/13/2019 : 22:14:30
|
I have an app with a very small window size that i need to minimize pretty often. The problem is that when this app is focused and I execute the action to minimize it with a gesture, I get minimized not this focused app, but the non-focused window where my gesture started.
So, is it possible to make action with focused/active window only? |
|
Rob
USA
2615 Posts |
Posted - 10/13/2019 : 22:24:37
|
I'm on my phone and no longer use the original StrokesPlus, so my syntax may be off.
But something like acMinimizeWindow(acGetForegroundWindow(), nil, nil)
Essentially instead of using the location of the mouse to determine the window to minimize, it uses a specific window instead; in this case, whatever window is in the foreground/is the active window. |
|
|
Orcus
11 Posts |
Posted - 10/13/2019 : 23:29:09
|
Thank you, that really works for win minimization.
But that doesn't look like a universal solution and the part of the problem still persists. I have different action for different apps for the one gesture. This gesture sends alt+f4 to any app to close it, but same gesture in Internet browser sends ctrl+w to just close the tab (and not the whole browser). So, this gesture still closes the non-focused window.
Could you please share any idea of how to implement your solution in this case? |
|
|
Rob
USA
2615 Posts |
Posted - 10/14/2019 : 08:08:38
|
What do you mean by "So, this gesture still closes the non-focused window."?
Keyboard input can only be received by the active window. Are you saying that the gesture is drawn over the inactive window, which then activates it and sending ALT+F4? I'm just trying to understand the exact situation. |
|
|
Orcus
11 Posts |
Posted - 10/14/2019 : 10:41:42
|
Sorry, my description is not quite correct.
When I draw the "close window" gesture over inactive Internet Browser, I see the StrokesPlus sends ctrl+w to the focused app (and not the alt+f4 as I expect it to send to close the focused app). So, StrokesPlus catches that the current app is Internet Browser, so it reads the gesture settings from the InternetBrowser section in StrokesPlus settings (Configure Actions tabs), and not the Global section. |
|
|
Rob
USA
2615 Posts |
Posted - 10/14/2019 : 12:14:53
|
So the selected window (app definition) is based on where the mouse was when the stroke button is pressed, as that's the only way to be sure of your intent.
However, by default I did not include activating the window where the gesture started, as I didn't want to make decisions for the user (note that in the new StrokesPlus.net version, I have this as an option and defaults to enabled due to overwhelming demand).
So you can either manually perform this activation for specific actions via acActivateWindow(nil, gsx, gsy) at the top of your script. Or you can enable this globally for all actions in your Global Lua (and ensuring the Before Script option is enabled in Preferences..if that's a thing, I can't recall, lol):
function sp_before_action(gnm, gsx, gsy, gex, gey, gwd)
acActivateWindow(nil, gsx, gsy)
end See https://www.strokesplus.com/forum/topic/316/dyk-acsendkeys-and-window-focus?SearchTerms=acactivatewindow and https://www.strokesplus.com/forum/topic/1379/close-window?SearchTerms=Sp_before_action |
|
|
Orcus
11 Posts |
Posted - 10/14/2019 : 15:48:44
|
Not sure if we really understand each other. Can't see how acActivateWindow(nil, gsx, gsy) should solve the problem.
I have the same gesture for two situation: Global - this gesture closes the window (alt+f4) Browser - this gesture closes the tab (ctr+w)
The problem is when browser window is maximized and NOT focused, and "another" app i want to control this moment IS focused. I want to close that "another" app, it is focused, so I just make the gesture to close the window. I perform this action over browser window because it is so big (and it is still non-focused).
Expected: StrokesPlus sends alt+f4 to the Focused window
Actual: StrokesPlus sends ctrl+w to the Focused window |
|
|
Rob
USA
2615 Posts |
Posted - 10/14/2019 : 16:43:36
|
Ah, okay I (believe) see what you mean.
So this relates to my first sentence. The qualifiers to determine the window driving if there is a matching defined application (in S+) is based on where the mouse is located when the gesture begins.
Meaning, if your gesture starts on the browser (even though it's in the background), that window is what is used and matches the action for, which then sends CTRL+F4 to the active window, since it is the only one which will receive the keyboard input. There is no way to change that, because S+ must use the location when the stroke button is pressed to determine things like if the window is ignored, and really there are several other important reasons for this which may not seem relevant based on your specific use case.
You either have to ensure your gesture begins on the "another" app window, or you remove the browser specific action and move the conditional logic into the global close.
For example:local activeWindowEXE = acGetExecutableName(acGetForegroundWindow(), nil, nil)
if activeWindowEXE == "chrome.exe" or activeWindowEXE == "firefox.exe" then
acSendKeys("^w")
else
acSendKeys("%{F_4}")
end |
|
|
Orcus
11 Posts |
Posted - 10/14/2019 : 17:16:20
|
That works fine, thank you. |
|
|
|
Topic |
|
|
|