Scroll volume when over Gui. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
V0RT3X
Posts: 243
Joined: 20 May 2023, 21:59
Contact:

Scroll volume when over Gui.

03 Apr 2024, 07:26

I came across this little script that detects when mouse cursor is over a script's Gui and when it leaves a script's Gui.
What I can't figure out is how to put hotkeys inside a function for simple volume up and down. What I'm attempting to do
is I have a volume script that display the volume percentage in a small Gui in the bottom right corner of my screen next to the clock.
I would like to be able to simply hover over that small Gui and adjust the volume with my scroll wheel. I know documentation
for #If shows in example 1 how to hover over the taskbar and scroll volume, but I am only wanting the area of the Gui to be the trigger.
image.png
image.png (14.21 KiB) Viewed 105 times

I would greatly appreciate if anyone can show me how to insert this...

Code: Select all

WheelUp::Send {Volume_Up 2}
WheelDown::Send {Volume_Down 2}
...into the below script to accomplish my end goal!!

Code: Select all

;;----------------Test Gui----------------
Gui Hover: Color, Silver
Gui Hover: 
    +AlwaysOnTop
    +Resize
    
Gui Hover: Show, x300 y300 w400 h300
    OnMessage(0x200, "OnMouseMoveHover")
    OnMessage(0x0201, "WM_LBUTTONDOWNdrag") 
Return
;;--------------------------------------------


OnMouseMoveHover()
    {
    MouseGetPos mx, my, IdWindow
    WinGetTitle, WinT, ahk_id %IdWindow%
    Title_buffer := WinT
    ToolTip The cursor is in Gui window %WinT%, 150, 3
    Loop, 
        {
        MouseGetPos mx, my, IdWindow  
            WinGetTitle, WinT, ahk_id %IdWindow%
                if !("" . Title_buffer = "" . WinT)
            {
        ToolTip 	 ; TooltipOff
        MsgBox, , , The cursor is now out of the`nGui window of %Title_buffer% GUI!, 2
                break
            }
        Sleep, 200
        }
    }
 
HoverGuiClose:
ExitApp
Thank You!!
tabr3
Posts: 18
Joined: 25 Feb 2024, 04:06

Re: Scroll volume when over Gui.  Topic is solved

03 Apr 2024, 08:28

Code: Select all


groupadd, blocked_soft, ahk_exe game1.exe ; optional

~wheelup::
CoordMode , mouse, screen
mousegetpos xxx, yyy
if (a_screenwidth - xxx <=50) and (a_screenheight - yyy <=50) ;  and winactive!(ahk_group blocked_soft)
Send {Volume_Up 2}
return

~wheeldown::
CoordMode , mouse, screen
mousegetpos xxx, yyy
if (a_screenwidth - xxx <=50) and (a_screenheight - yyy <=50)
Send {Volume_Down 2}
return
I will just do it this way , don't know how to deal with #if...
User avatar
V0RT3X
Posts: 243
Joined: 20 May 2023, 21:59
Contact:

Re: Scroll volume when over Gui.

03 Apr 2024, 09:01

Thanks for this @tabr3. It works, but also works across the entire taskbar on my second monitor. I'll have to see if I can figure out
if this can be fine tuned to only be a 50x40 pixel area. But for the time being it's a lot better than what I had going!! Thank you!!

EDIT: This actually turned out to be exactly what I needed! Thank you @tabr3!!
My modification below using Soundset instead of sending Volume_Up/Down as the latter shows a built in display while scrolling.
With your code I was able to use just the selected area of the taskbar I wanted. Not using the volume Gui as I was originally attempting,
but considering I'm keeping my volume Gui where it is, this is perfect, and will definitely find future uses.

Code: Select all

TaskbarAreaX := A_ScreenWidth - 153  ; Pixels from the right side of the screen.
TaskbarAreaY := A_ScreenHeight - 39  ; Pixels from the right side of the screen.

;;--------------------------------- 
~WheelUp:: 
CoordMode, Mouse, Screen
MouseGetPos, xPos, yPos

if (xPos >= TaskbarAreaX && yPos >= TaskbarAreaY && xPos <= (TaskbarAreaX + 150) && yPos <= (TaskbarAreaY + 40))
{
SoundSet +2
}
Return
;;--------------------------------- 
~WheelDown:: 
CoordMode, Mouse, Screen
MouseGetPos, xPos, yPos

if (xPos >= TaskbarAreaX && yPos >= TaskbarAreaY && xPos <= (TaskbarAreaX + 150) && yPos <= (TaskbarAreaY + 40))
{
SoundSet -2
}
Return

-the dotted line box is for illustration only...
image.png
image.png (8.48 KiB) Viewed 74 times
My final Volume Gui script. Covers the Notification Center, but still accessible through click-through. (I never use it)
Volume is scrollable from the Speakers icon through the system clock, and over the Notification Center as shown above.
Spoiler

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 126 guests