Wheeling the IE wepage underneath another one

Get help with using AutoHotkey and its commands and hotkeys
paik1002
Posts: 355
Joined: 28 Nov 2015, 02:45

Wheeling the IE wepage underneath another one

10 Apr 2017, 07:42

There are two marginally overlapping IE webpages, say IE_A is on top of IE_B and active.

How do I wheeldown/up the webpage on IE_B without winactivating IE_B?

The following script only seems to work on an active IE, namely IE_A.

Code: Select all

$wheelDown::
$wheelUp::
{
	MouseGetPos,,, WheelID, WheelNN
	if WheelNN contains Internet Explorer_Server1
	{
		ControlFocus, %WheelNN%, ahk_id %WheelID%
		KeyName:=SubStr(A_ThisHotkey,2)
		controlclick, %WheelNN%, ahk_id %WheelID%,, %KeyName%
	}
	return
}
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wheeling the IE wepage underneath another one

11 Apr 2017, 20:43

Great script, it just needed the 'ControlFocus' line commented out.

I did some tests anyhow:

Code: Select all

q:: ;scroll window under cursor - send WheelDown
MouseGetPos,,, WheelID, WheelNN
;ControlSend, %WheelNN%, {WheelDown}, ahk_id %WheelID% ;didn't work
ControlClick, %WheelNN%, ahk_id %WheelID%,, WheelDown, 10
;SendInput {WheelDown} ;works for active window
return

w:: ;scroll window under cursor - send PgDn
MouseGetPos,,, WheelID, WheelNN
ControlSend, %WheelNN%, {PgDn}, ahk_id %WheelID%
return

e:: ;scroll window under cursor - scroll via COM
MouseGetPos,,, hWnd
oWB := WBGet("ahk_id " hWnd)
Loop, 4
	oWB.document.parentWindow.scrollBy(0, 16)
oWB := ""
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
paik1002
Posts: 355
Joined: 28 Nov 2015, 02:45

Re: Wheeling the IE wepage underneath another one

12 Apr 2017, 00:03

I am using a Windows 7 based PC at work, and a Windows 10 PC at home.
To this point, my script seems to work perfectly at home.
However, the same script is found buggy or conditionally functional at work.

For example,
if the target IE window has width > 1090 and positioned at win_left_hand_side_x_coord < 1620, then the script works fine. However, if the same window is adjusted to have width < 1090 and win_left_hand_side_x_coord > 1620, then it would not work at all.
The script work only when a certain width / position value is met.

I also found that it is really not a problem about overlapped IE windows.
AHK is buggy even with single IE windows.

It is odd that AHK should be selective about IE window size and screen position. It makes no sense at all.
The only solution that I have available now is to upgrade the OS (or the browser) at work, which of course is not a realistic option.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wheeling the IE wepage underneath another one

12 Apr 2017, 15:59

I was using Windows 7, although with Aero mode off, and admittedly the cursor was approximately over the centre of the window when I tested.

Have you tested with Aero mode off?

Code: Select all

q::
MouseGetPos, vPosX, vPosY, hWnd, vCtlClassNN
WinGetTitle, vWinTitle, % "ahk_id " hWnd
WinGetClass, vWinClass, % "ahk_id " hWnd
MsgBox, % vWinTitle "`r`n" vWinClass "`r`n" vCtlClassNN
return
Is window identification correct near the centre of a window, but incorrect near the borders?

You could try tests with AccViewer also.

I have heard that there have been issues with detecting the window under the cursor and Aero mode, but am yet to hear the full details of the problem, or whether there are solutions/workarounds.

For example I heard that WM_NCHITTEST was giving incorrect results in certain circumstances, something I use for a 'right-click minimise button to minimise to system tray' script.

[EDIT:] I see references to the dll functions GetCursorPos and WindowFromPoint in the script2.cpp source code file.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
paik1002
Posts: 355
Joined: 28 Nov 2015, 02:45

Re: Wheeling the IE wepage underneath another one

13 Apr 2017, 01:02

Thank you for taking interest in this matter.

My PC at work has Aero mode set to OFF already.

I also verified the window identification on locations at the center and near the borders, and they are no different.

It is not even a mouse problem, since I have tried it on several mice with a scroll wheel.

It is not so difficult to test the situation either.
Just moving the IE window from one location to another (and back) will replicate the problem,
e.g. moving IE from the center to the right hand side of the monitor and scrolling will disable the mouse scroll function.

Then I tried replacing the mouse scroll hotkey with a keyboard hotkeys, e.g. PgDn/PgUp
(thereby using controlsend instead of controlclick).
Guess what?
The problem has vanished for good!

It may be premature to conclude, but I think that the AHK command controlclick is buggy or unreliable.
(Unfortunately, controlsend does not support the wheel scroll command.)

Code: Select all

$PgDn::
$PgUp::
{
	MouseGetPos,,, WheelID, WheelNN
	if WheelNN contains Internet Explorer_Server1
	{
		ControlFocus, %WheelNN%, ahk_id %WheelID%		; this line is optional(not required, but just in case...)
		KeyName:=SubStr(A_ThisHotkey,2)
		controlsend, %WheelNN%, {%KeyName%}, ahk_id %WheelID%	; any work-around for mouse wheeldown/wheelup function, using controlsend?
	}
	return
}
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wheeling the IE wepage underneath another one

13 Apr 2017, 04:01

Although I could have a look at the source code for ControlClick, I'm not sure if I'll notice anything. I will have a go anyway when I get the chance.

This:
AutoHotkey Downloads
https://autohotkey.com/download/
has a link to the source code:
GitHub - Lexikos/AutoHotkey_L: AutoHotkey - macro-creation and automation-oriented scripting utility for Windows.
https://github.com/Lexikos/AutoHotkey_L/

One issue I've noticed even when Aero mode is off, is sometimes I'm scrolling with PgUp/PgDn, and then I go to scroll again and it randomly gets stuck. I then zoom in, and zoom out by 5%, using ctrl +/- and scrolling works again.

If I go to https://www.google.com/ (which renavigates to https://www.google.co.uk/ in my case), scroll is stuck to begin with. Using ctrl +/-, doesn't work in this case, although if I press tab to escape the input field, PgUp/PgDn for scrolling works.

==================================================

[EDIT:]
Btw have you experienced this problem on any other programs?

Btw so you are saying:
w > 1090, x < 1620, works
w < 1090, x > 1620, doesn't work
And these are the properties of the (non-active) window underneath the cursor. And that the problem occurs even when it is the active window?
And since for example my screen resolution is w1280 h720, you have a massive screen, or a dual screen.
w > 1090, x > 1620, does it work?
w < 1090, x < 1620, does it work?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
paik1002
Posts: 355
Joined: 28 Nov 2015, 02:45

Re: Wheeling the IE wepage underneath another one

14 Apr 2017, 12:23

jeeswg wrote:Although I could have a look at the source code for ControlClick, I'm not sure if I'll notice anything. I will have a go anyway when I get the chance.

This:
AutoHotkey Downloads
https://autohotkey.com/download/
has a link to the source code:
GitHub - Lexikos/AutoHotkey_L: AutoHotkey - macro-creation and automation-oriented scripting utility for Windows.
https://github.com/Lexikos/AutoHotkey_L/

One issue I've noticed even when Aero mode is off, is sometimes I'm scrolling with PgUp/PgDn, and then I go to scroll again and it randomly gets stuck. I then zoom in, and zoom out by 5%, using ctrl +/- and scrolling works again.

If I go to https://www.google.com/ (which renavigates to https://www.google.co.uk/ in my case), scroll is stuck to begin with. Using ctrl +/-, doesn't work in this case, although if I press tab to escape the input field, PgUp/PgDn for scrolling works.

==================================================

[EDIT:]
Btw have you experienced this problem on any other programs?

Btw so you are saying:
w > 1090, x < 1620, works
w < 1090, x > 1620, doesn't work
And these are the properties of the (non-active) window underneath the cursor. And that the problem occurs even when it is the active window?
And since for example my screen resolution is w1280 h720, you have a massive screen, or a dual screen.
w > 1090, x > 1620, does it work?
w < 1090, x < 1620, does it work?
Yes, but those numbers are just one instance, and may differ depending on other factors.
The combination of window size, window postion, and monitor resolution.

FYI, those numbers were found on the monitor (single) at work, which supports a resolution of 1920x1080.
I found it different for another monitor (e.g. 4K monitor).

But generally speaking, placing the browser off-center (far right or left-hand-side of the screen) will disable the mouse scroll function.
Exactly by how much? That may depend on window size and monitor resolution.
This suggests that the mouse wheel function via controlclick only works in the central part of the screen for a not-too-small window size.

Here are some other updates:
1) Browser that is active or non-active, overlapping or non-overlapping, none of it seems to matter. Problem occurs in all cases.
2) Found that mouse scroll using controlclick is unreliable even on a Win10 PC. So, no luck with updating the OS.
3) Mouse scroll using controlclick is unreliable with IE and Chrome. Maybe AHK has an issue with browsers in general?
4) Tried assigning the mouse scroll function from the wheel to a different mouse button (on a programmable mouse). No difference.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wheeling the IE wepage underneath another one

14 Apr 2017, 14:22

This is very interesting, I've done a few tests and found out some things, possibly the more specific underlying problem.

Code: Select all

q:: ;move/resize IE window to fill the left third of the screen
w:: ;move/resize IE window to fill the middle third of the screen
WinGet, hWnd, ID, A
WinGetClass, vWinClass, % "ahk_id " hWnd
if vWinClass not in IEFrame
	return
WinGetPos,,,, vPosH, ahk_class Shell_TrayWnd
if InStr(A_ThisHotkey, "q")
	WinMove, % "ahk_id " hWnd,, 0, 0, % A_ScreenWidth/3, % A_ScreenHeight-vPosH
if InStr(A_ThisHotkey, "w")
	WinMove, A,, % A_ScreenWidth/3, 0, % A_ScreenWidth/3, % A_ScreenHeight-vPosH
return
Try using the middle mouse button to scroll, then press q or w to move the window, and try scrolling again (by physically using the middle mouse button).

Also move the window to the left third via AHK, then manually move it a little bit (e.g. a few pixels), then move it to the middle third via AHK, and try to scroll.

Also try PgDn/PgUp as well as WheelUp/WheelDown.

==================================================

Basically, what I see is that when you move the window via AHK to the left third of the screen, scrolling via WheelUp/WheelDown is affected (it can stop working), but when you move it back it to the middle via AHK, it works again. PgUp/PgDn always seems to work.

Also, if you get scrolling (via physically using the middle mouse button) working, when the window is in the left third, (by manually moving the window a tiny bit,) and then move the window via AHK to the middle of the screen, and try to scroll (via physically using the middle mouse button), you get the same problem, but this time the problem (of scrolling not working) occurs when the window is in the *middle* of the screen. (If you then move the window back to the left third via AHK, manual scrolling works again, on the *left* third).

Chrome and Firefox have the same problem as Internet Explorer. Notepad does not have the problem.

If you move the window manually, it appears that scrolling still works. So the problem seems to be if you move the window via AutoHotkey (via WinMove).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wheeling the IE wepage underneath another one

12 May 2017, 07:21

Does anybody have any ideas for an alternative to WinMove that might prevent this problem from happening?

@paik1002, do you have anything else to say about this problem?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wheeling the IE wepage underneath another one

25 May 2017, 20:50

The information I put above is essentially correct, but misses the point ...

I think the issue is simply this:
- When you press WheelDown, it will act on the active window. If the active window is Internet Explorer, it will act on the control/element under the cursor.
- When you press PgDn, it will act on the active window. If the active window is Internet Explorer, scrolling is applied to the active element (the control/element under the cursor is irrelevant).

So to use WheelDown correctly, the window you want to scroll must be active, and for some programs the cursor must be over a specific control/element.

Two methods to scroll down a non-active Internet Explorer window:

Code: Select all

q:: ;send PgDn to Internet Explorer
ControlSend, Internet Explorer_Server1, {PgDn}, ahk_class IEFrame
return

w:: ;scroll Internet Explorer via COM
WinGet, hWnd, ID, ahk_class IEFrame
oWB := WBGet("ahk_id " hWnd)
oWB.document.parentWindow.scrollBy(0, 16)
oWB := ""
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: Alexander2, Bing [Bot], brecht2202, hoppfrosch, jameskhalil, Kriss, Qtic, Rohwedder, teadrinker and 53 guests