Rank: Newbie
Groups: Approved
Joined: 11/6/2019(UTC) Posts: 8
Thanks: 3 times
|
Hello I am using the example script to switch chrome tabs by mouse wheel script. I change some of them, and it works well, My script is like below: Code:if (wheel.Window.Process.MainModule.ModuleName == "chrome.exe"
|| wheel.Window.Process.MainModule.ModuleName == "msedge.exe") {
// is the mouse in the top 64 pixel area of the window?
if (wheel.Y >= wheel.Window.Rectangle.Top
&& wheel.Y <= wheel.Window.Rectangle.Top + 64) {
if (wheel.Delta < 0) {
// mouse wheel scrolled up
sp.SendKeys("^{TAB}");
} else {
// mouse wheel scrolled down
sp.SendKeys("^+{TAB}");
}
} else {
// Default, pass mouse wheel message onto the original control
sp.MouseWheel(wheel.Point, false, wheel.Delta);
}
} else {
// Default, pass mouse wheel message onto the original control
sp.MouseWheel(wheel.Point, false, wheel.Delta);
}
But I found it not work when I was focusing on another window.For example: I am focusing on the Explorer, and I want to switch the chrome tabs without change focus on the chrome. So I move the mouse on the top area of the window where the chrome tabs are. I scroll the mouse wheel but nothing happens. But when I move the mouse to the page area and scroll the wheel, the page scrolls. That is the original funtion of windows 10. I want to have the same function on scrolling the chrome tabs by mouse wheel script. What can I do to make it works on mouse wheel script?
|
|
|
|
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)
|
For this functionality, it's simply sending CTRL+Tab or CTRL+SHIFT+Tab. However, for those key strokes to work, Chrome has to be the active window, otherwise whatever is the active window will receive the keystrokes. While many have tried, unfortunately you cannot post messages to simulate keystrokes to other windows. Sometimes this can work, but not often and is usually unstable, so I don't even bother recommend anyone trying it. For the record, I did just try it in Chrome, exactly mimicking the same messages sent by CTRL+Tab, but it does not work. The reason some things work is because they're programmed to accept the mouse wheel message, even if they're not the active window. But in this case, Chrome doesn't support the mouse wheel changing tabs, so we have to send keystrokes - which means Chrome needs to be the active window. If you want the script to activate Chrome first, you can add one line as shown below: Code:if (wheel.Window.Process.MainModule.ModuleName == "chrome.exe"
|| wheel.Window.Process.MainModule.ModuleName == "msedge.exe") {
// is the mouse in the top 64 pixel area of the window?
if (wheel.Y >= wheel.Window.Rectangle.Top
&& wheel.Y <= wheel.Window.Rectangle.Top + 64) {
wheel.Window.RootWindow.Activate(); // <-- Activate Chrome/Edge
if (wheel.Delta < 0) {
// mouse wheel scrolled up
sp.SendKeys("^{TAB}");
} else {
// mouse wheel scrolled down
sp.SendKeys("^+{TAB}");
}
} else {
// Default, pass mouse wheel message onto the original control
sp.MouseWheel(wheel.Point, false, wheel.Delta);
}
} else {
// Default, pass mouse wheel message onto the original control
sp.MouseWheel(wheel.Point, false, wheel.Delta);
}
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 11/6/2019(UTC) Posts: 8
Thanks: 3 times
|
Thank you for your reply. Since it is difficult to post messages to simulate keystrokes. Maybe the best way is to activate chrome first. I tried your activate chrome code and it works well.
|
|
|
|
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