how can i combine 2 ahk files

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iiyoo
Posts: 1
Joined: 24 Nov 2022, 22:50

how can i combine 2 ahk files

Post by iiyoo » 26 Nov 2022, 01:58

how can i combine the following 2 ahk codes, or just run 1 thing to achieve 2 functions.
Now the notification bar has two identical icons, which is a bit ugly. If possible, could you add the following function: alt +Wheel to adjust the brightness

Code: Select all

;scroll middle botton to change the browser tabs
#IfWinActive ahk_class Chrome_WidgetWin_1
~$WheelDown::
~$WheelUp::
    MouseGetPos,, ypos
    If (ypos>40) Or (ypos<0)
    Return
    IfEqual,A_ThisHotkey,~$WheelDown, Send ^{PgDn}
    Else Send ^{PgUp}
Return
~LButton::
    WinGetPos,,, w, h, A
    MouseGetPos,xpos, ypos
    WinGet,Mom,MinMax
    If ((ypos>45)And(Mom<1))Or((ypos>28)And(Mom>0)) Or (ypos<0)
    Return
    If (A_PriorHotkey="~LButton") and (A_TimeSincePriorHotkey<200)
    send ^w
Return

Code: Select all

;on windows task bar ,scroll up to volume+,scroll down to volume-
~WheelUp::
	if (existclass("ahk_class Shell_TrayWnd")=1)  
	Send,{Volume_Up}  
	Return  
~WheelDown::  
	if (existclass("ahk_class Shell_TrayWnd")=1)  
	Send,{Volume_Down}  
	Return  
~MButton::  
	if (existclass("ahk_class Shell_TrayWnd")=1)  
	Send,{Volume_Mute}  
	Return  

Existclass(class)  
{  
	MouseGetPos,,,win  
	WinGet,winid,id,%class%  
	if win = %winid%  
	Return,1  
	Else  
	Return,0  
}
Return

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: how can i combine 2 ahk files

Post by mikeyww » 26 Nov 2022, 05:59

Welcome to this AutoHotkey forum!

An example is below.

Code: Select all

#If mouseOver("ahk_class Shell_TrayWnd")
WheelUp::SoundSet +5
WheelDown::SoundSet -5
MButton::SoundSet, +1,, Mute

#If WinActive("ahk_class Chrome_WidgetWin_1") ; Class used by various programs
WheelUp::Send ^{PgUp}
WheelDown::Send ^{PgDn}
#If

mouseOver(winTitle) {
 MouseGetPos,,, hWnd
 Return WinExist(winTitle " ahk_id" hWnd)
}
Here is a brightness script that you can use: viewtopic.php?p=365164#p365164

Explained: Variant hotkeys
If more than one variant is eligible to fire, only the one closest to the top of the script will fire. The exception to this is the global variant (the one with no #IfWin criteria): It always has the lowest precedence; therefore, it will fire only if no other variant is eligible (this exception does not apply to hotstrings).

Post Reply

Return to “Ask for Help (v1)”