Scroll window on top

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Scroll window on top

Post by jrachr » 24 Jan 2022, 04:15

Have looked but see nothing so I will ask. Let's say I have my browser open Fullscreen and open my task manager which is not full screen. Is it possible with ahk to scroll task manager window without having to move cursor to task manager window. IE. Just scroll the open window on top.

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Scroll window on top

Post by Rohwedder » 24 Jan 2022, 04:59

Hallo,
try:

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Run *RunAs "%A_ScriptFullPath%"
q::ControlClick,, ahk_exe Taskmgr.exe,, WheelUp
w::ControlClick,, ahk_exe Taskmgr.exe,, WheelDown

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 24 Jan 2022, 05:26

Thank you. Will try when I get home.

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 24 Jan 2022, 05:34

@rohwedder. Question. Haven't tried your script yet but am I safe in assuming that it would only scroll an open task manager on top window? If so is it possible to scroll any open random window on top the same way except remove the task manager. Exe from the script? Tk's

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Scroll window on top

Post by boiler » 24 Jan 2022, 05:36

Try changing it to this to have it act on the active window even if the mouse pointer is above another window:

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Run *RunAs "%A_ScriptFullPath%"
q::ControlClick,, A,, WheelUp
w::ControlClick,, A,, WheelDown

You could even still use your mouse wheel instead of different keys. It just acts on the active window instead of what's under the mouse:

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Run *RunAs "%A_ScriptFullPath%"
WheelUp::ControlClick,, A,, WheelUp
WheelDown::ControlClick,, A,, WheelDown

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 24 Jan 2022, 05:41

@boiler. Thank you. Will have a look at this and get back to you. Cheer's

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Scroll window on top

Post by boiler » 24 Jan 2022, 05:44

Sure. If you want, you can add a hotkey to toggle the mouse wheel between active window and mouse over. The following will allow you to use Ctrl+Tab to toggle between the two modes:

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Run *RunAs "%A_ScriptFullPath%"
WheelUp::ControlClick,, A,, WheelUp
WheelDown::ControlClick,, A,, WheelDown
^Tab::Suspend

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 24 Jan 2022, 19:00

Hi guys . I'm back. This might not be possible. Just realized I have other stuff attached. I tried both codes rohwedder and boiler's. But both came up in line 3 as no application associated Here is my current Mouse script

Code: Select all

#SingleInstance, Force
#KeyHistory 
#Persistent
;#Warn				       


^WheelUp:: VKAF                                                                                                    ;Zoom Key+(Volume Control Up)
Return

^WheelDown:: VKAE                                                                                                  ;Zoom Key-(Volume Control Down)
Return


WheelLeft::
Return


WheelRight::
Return

MButton::Run, E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Firefox\Firefox Bookmark's.ahk           ;Open Firefox Bookmark's
Return




#If MouseIsOver("ahk_class Shell_TrayWnd")                                                                         ;Raise or lower volume when arrow over taskbar
   WheelUp::Send {Volume_Up}
   WheelDown::Send {Volume_Down}
#If

MouseIsOver(WinTitle)
{  MouseGetPos,,, Win
   Return WinExist(WinTitle . " ahk_id " . Win)
}                                                                                   
Return

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Scroll window on top

Post by boiler » 24 Jan 2022, 19:02

Do you have AHK installed such that .ahk files are associated with it? Can you double-click on a script in File Explorer to have it run?

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 24 Jan 2022, 19:13

I can click on any of my scripts which are located in my ahk folder and they work fine. Strange thing is this error comes up but then script shows up in my window tray. what doesn't work like I wantis if my browser is open fullscreen and IE I open file explorer I still have to move cursor over Explorer window for it to scroll. Oh well. Not the end of the world. It is windows 11.

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Run *RunAs "%A_ScriptFullPath%"
WheelUp::ControlClick,, A,, WheelUp
WheelDown::ControlClick,, A,, WheelDown

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Scroll window on top

Post by boiler » 24 Jan 2022, 19:20

I'm finding that FileExplorer doesn't seem to respond to the ControlClick, as is true for many applications. It works for me if I try it with Chrome and another program's window like Notepad or VS Code.

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 24 Jan 2022, 19:24

@boiler. As i said no big deal. Just a thought. Not something I would use that much but was interested to see if it was possible. It also could be something in this new Windows 11. Tk's for trying. Cheer's

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Scroll window on top

Post by boiler » 24 Jan 2022, 19:33

Sure. Maybe Rohwedder or someone else knows a way to get File Explorer to respond or to accomplish this in some other way.

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Scroll window on top

Post by boiler » 24 Jan 2022, 19:35

I'm curious, though. What error comes up? It's not just asking if you want to "allow this app from an unknown publisher to make changes to your device?"

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 24 Jan 2022, 19:54

@boiler. Word for word And then when I close it. the hotkey icon showing scroll.ahk is there but when I have firefox open and open task manager it won't scroll task manager and then I have to double click to get my firefox to scroll again. But there is also the issue of my using the wheel in the taskbar to control volume. Not sure how much of a difference that would make turning it off.
---------------------------
Scroll.ahk
---------------------------
Error: Failed attempt to launch program or document:
Action: <C:\Users\Jr\Desktop\Scroll.ahk>
Verb: <RunAs>
Params: <>

Specifically: No application is associated with the specified file for this operation.



Line#
002: if !A_IsAdmin
---> 003: Run,*RunAs "%A_ScriptFullPath%"
004: Return
004: ControlClick,,A,,WheelUp
004: Return
005: ControlClick,,A,,WheelDown
005: Return
006: Exit
007: Exit

The current thread will exit.
---------------------------
OK
---------------------------

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Scroll window on top

Post by boiler » 24 Jan 2022, 22:32

Weird. I don’t know what would cause that if your system knows what .ahk files are.

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 25 Jan 2022, 17:06

@rohwedder. Haven't heard from you. Any thoughts? Lol. Or is that why I haven't heard any more input from you. All I want is the ability to not have to move the cursor and be able to scroll the open window on top whatever it happens to be. Task manager, explorer, notepad, etc. Just to save the half second. I am more curious about if it is possible. Or does the cursor have to be in the active window to scroll?

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Scroll window on top

Post by boiler » 25 Jan 2022, 17:51

jrachr wrote: All I want is the ability to not have to move the cursor and be able to scroll the open window on top whatever it happens to be. Task manager, explorer, notepad, etc. Just to save the half second. I am more curious about if it is possible. Or does the cursor have to be in the active window to scroll?
As I mentioned, it works with some programs, and not others. It works for me with all the apps you mentioned and more except File Explorer. Did you try it with those?

You can still have it work for all windows where it is capable, and you can even have it show a ToolTip reminder for when the active window requires the mouse to be over it and have it work the normal way once the mouse is over it, like with this script (current exception that it works with is File Explorer but could be made to work with others as well):

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Run *RunAs "%A_ScriptFullPath%"

#If WinActive("ahk_class CabinetWClass")
$WheelUp::
$WheelDown::
	if MouseIsOver("ahk_class CabinetWClass") {
		ToolTip
		Send, % "{" SubStr(A_ThisHotkey, 2) "}"
	} else {
		ToolTip, Mouse must be over the current active window to scroll it
		SetTimer, ToolTipOff, -1000
	}
return

#If
WheelUp::ControlClick,, A,, WheelUp
WheelDown::ControlClick,, A,, WheelDown

ToolTipOff:
	ToolTip
return

MouseIsOver(WinTitle) {
    MouseGetPos,,, Win
    return WinExist(WinTitle . " ahk_id " . Win)
}

jrachr
Posts: 532
Joined: 01 Mar 2021, 17:33

Re: Scroll window on top

Post by jrachr » 25 Jan 2022, 18:57

Will play around and see what happens. Tk's boiler. Cheer's

Post Reply

Return to “Ask for Help (v1)”