Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Dear, Rob The following gesture works only when I activate the current window by left-clicking. When I click on the desktop by left-clicking and then execute the gesture in other windows, it is still recognized as the desktop. Code:if(action.Control.HWnd.ToInt32() == sp.DesktopWindowListView().HWnd.ToInt32()) {
//do nothing
}else{
sp.SendKeys("%{F4}")
//action.Window.SendClose();
}
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
This is behaving how you have the script coded. It is comparing the Control below the mouse cursor to the Desktop. Since the mouse is over the Explorer window (whether it is the active window or not), the Control.HWND does not match the Desktop HWnd, so it executes your else {} and sends Alt+F4. Since the Desktop is the active window, it receives the Alt+F4 command and shows the Shutdown Windows prompt. Sending key strokes are always received by whatever window currently is active/has focus. That is why action.Window.SendClose() would work even if the window is not active, since it posts a message directly to the window. Of course, some applications may not respond to this command and Alt+F4 might be needed. There are two ways to resolve this: - Enable the option Options > General > Always Activate Window Where Gesture Began, this will ensure the window below the gesture start is activated before any action script is executed
- Use the script below, which will do the same thing as the above option, but instead of all scripts, it will only do it for this action/script
Code:if(action.Control.HWnd.ToInt32() == sp.DesktopWindowListView().HWnd.ToInt32()) {
//do nothing
} else {
//If the click did not happen on the desktop and the active window is not
//the window where the click occurred, active the window below the mouse
//before sending Alt+F4
if(sp.ForegroundWindow().HWnd.ToInt32() != action.Window.HWnd.ToInt32()) {
action.Window.Activate();
}
sp.SendKeys("%{F4}")
//action.Window.SendClose();
}
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Thank you, Rob. Both schemes work well. I have one last question here. Is there a way to make the following hotkeys work properly?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
That is a little tricky. While you can sort of trick it into working, I will state that this may only work with some applications. Code://Release the Alt key since you're still pressing it
sp.SendAltUp();
//Send Alt Down then Up to escape menu activation
sp.SendAltDown();
sp.SendAltUp();
//Send the Left arrow key
sp.SendVKey(vk.LEFT);
//Set the Alt key as pressed down again, so you can press
//the hotkey again without releasing Alt first
sp.SendAltDown();
Ultimately, pressing the Alt key can initiate a menu/item activation sequence, which requires you to press and release the Alt key to escape from, which is what the above script attempts to do so the Left key can be sent by itself.
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
I know what you mean, because ALT is used as the modifier key in the script, so it can't work properly in all software. It seems that this hotkey can't work properly. Thank you, Rob.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Did you try placing the vk.LEFT line with this instead?
sp.SendModifiedVKeys([vk.LMENU], [vk.LEFT]);
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Yeah, I did, but it didn't work on my computer. So I give it up.
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 161 Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
Originally Posted by: Rob This is behaving how you have the script coded.
It is comparing the Control below the mouse cursor to the Desktop. Since the mouse is over the Explorer window (whether it is the active window or not), the Control.HWND does not match the Desktop HWnd, so it executes your else {} and sends Alt+F4. Since the Desktop is the active window, it receives the Alt+F4 command and shows the Shutdown Windows prompt. Sending key strokes are always received by whatever window currently is active/has focus. That is why action.Window.SendClose() would work even if the window is not active, since it posts a message directly to the window. Of course, some applications may not respond to this command and Alt+F4 might be needed. There are two ways to resolve this: - Enable the option Options > General > Always Activate Window Where Gesture Began, this will ensure the window below the gesture start is activated before any action script is executed
Use the script below, which will do the same thing as the above option, but instead of all scripts, it will only do it for this action/script Code:if(action.Control.HWnd.ToInt32() == sp.DesktopWindowListView().HWnd.ToInt32()) {
//do nothing
} else {
//If the click did not happen on the desktop and the active window is not
//the window where the click occurred, active the window below the mouse
//before sending Alt+F4
if(sp.ForegroundWindow().HWnd.ToInt32() != action.Window.HWnd.ToInt32()) {
action.Window.Activate();
}
sp.SendKeys("%{F4}")
//action.Window.SendClose();
}
I need to set it in a Hotkey and use the Touchpad Gesture program Gesturesign to send Alt+F4. Could the Window under the mouse (not the foreground window) be active when executing the Hotkey?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Quote:Could the Window under the mouse (not the foreground window) be active when executing the Hotkey? Sure, this should do it: Code:sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).Activate();
|
1 user thanked Rob for this useful post.
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close