Skip to content

Commit 63d71ef

Browse files
committed
Add option to disable admin app notification #106
1 parent 7ccffad commit 63d71ef

File tree

6 files changed

+34
-46
lines changed

6 files changed

+34
-46
lines changed

src/MicMute.ahk

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -555,27 +555,32 @@ parseArgs(){
555555
}
556556

557557
registerWindowHook(){
558-
DllCall( "RegisterShellHookWindow", UInt,A_ScriptHwnd )
559-
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
560-
OnMessage( MsgNum, "onWindowChange" )
558+
DllCall("RegisterShellHookWindow", "UInt", A_ScriptHwnd)
559+
msgNum := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK")
560+
OnMessage(msgNum, "onWindowChange")
561561
}
562562

563563
onWindowChange(wParam, _lParam){
564-
if(wParam=1)
565-
showElevatedWarning()
564+
if (wParam = 1 && IsActiveAppAdmin()) {
565+
TrayTip, MicMute, Detected an application running with administrator privileges. You need to run MicMute as administrator for the hotkeys to work with it.
566+
onUpdateState(mic_controllers[1])
567+
}
566568
}
567569

568-
showElevatedWarning(){
569-
static lastP:=""
570+
IsActiveAppAdmin(){
571+
static lastProcess:=""
572+
if (A_IsAdmin || !config_obj.NotifyForAdminApps)
573+
return false
574+
570575
WinGet, pid, pid, A
571576
WinGet, pName, ProcessName, A
572-
if(A_IsAdmin || !pName || pName == lastP)
573-
return
574-
if(util_isProcessElevated(pid)){
577+
if (!pName || pName == lastProcess)
578+
return false
579+
580+
if (util_isProcessElevated(pid)){
575581
util_log("[Main] Detected elevated app: " pName " (" pid ")")
576-
TrayTip, MicMute, Detected an application running with administrator privileges. You need to run MicMute as administrator for the hotkeys to work with it.
577-
lastP:= pName
578-
onUpdateState(mic_controllers[1])
582+
lastProcess:= pName
583+
return true
579584
}
580585
}
581586

src/UI/config/UI.ahk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ UI_reset(){
137137
ui_obj.doc.getElementById("VoicemeeterIntegration").setAttribute("checked", 1)
138138
else
139139
ui_obj.doc.getElementById("VoicemeeterIntegration").removeAttribute("checked")
140+
if(config_obj.NotifyForAdminApps)
141+
ui_obj.doc.getElementById("NotifyForAdminApps").setAttribute("checked", 1)
142+
else
143+
ui_obj.doc.getElementById("NotifyForAdminApps").removeAttribute("checked")
140144
ui_obj.doc.getElementById("PreferTheme").value:= config_obj.PreferTheme
141145
}
142146

src/UI/config/UITemplates.ahk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,6 @@ global template_link:= "<link rel='stylesheet' id='css_{1:}' href='{2:}'>"
145145
,{ selector: ".volume-lock-label"
146146
, string: "Lock the microphone's volume to a specific value"}
147147
,{ selector: ".ForegroundAppsOnly-label"
148-
, string: "Require apps to be in the foreground to trigger a profile change"}]
148+
, string: "Require apps to be in the foreground to trigger a profile change"}
149+
,{ selector: ".NotifyForAdminApps-label"
150+
, string: "Show a notification when an admin app is detected"}]

src/UI/config/html/UI.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,14 @@
711711
<span>Voicemeeter integration</span>
712712
</label>
713713
</div>
714+
<!-- Notify For Admin Apps -->
715+
<div class="tag is-small option has-tooltip" onclick="ahk.UI_onGlobalOption('NotifyForAdminApps',1);this.blur()" tabindex=0
716+
onkeydown="switch(event.keyCode){case 32:case 13:this.click()}" role="button" aria-pressed="false">
717+
<label class="checkbox">
718+
<input type="checkbox" name="NotifyForAdminApps" id="NotifyForAdminApps" disabled>
719+
<span class="NotifyForAdminApps-label">Notify For Admin Apps</span>
720+
</label>
721+
</div>
714722
</div>
715723
<div class="column is-4">
716724
<!-- default profile -->

src/config/Config.ahk

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ForceMicrophoneState := 0
99
VoicemeeterPath := ""
1010
VoicemeeterIntegration := 0
11-
11+
NotifyForAdminApps := 1
1212
Version := ""
1313

1414
__New(p_DefaultProfile := "") {
@@ -61,14 +61,6 @@
6161

6262
; Update the config version
6363
this.Version := A_Version
64-
65-
; Ensure compatibility with old versions
66-
if (this.UseCustomSounds) {
67-
for i, profile in this.profiles {
68-
profile.SoundFeedbackUseCustomSounds := this.UseCustomSounds
69-
}
70-
}
71-
this.Delete("UseCustomSounds")
7264
}
7365

7466
exportConfig() {

src/config/ProfileTemplate.ahk

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,6 @@
2727
, UseCustomIcons: 0 }
2828

2929
if (IsObject(p_name_Obj)) {
30-
; Ensure compatibility with old versions
31-
onMuteOnly := p_name_Obj.Delete("OverlayOnMuteOnly")
32-
if (onMuteOnly)
33-
this.OnscreenOverlay.ShowOnState := onMuteOnly
34-
35-
; Ensure compatibility with old versions
36-
if (!IsObject(p_name_Obj.OnscreenOverlay)){
37-
this.OnscreenOverlay.Enabled := p_name_Obj.Delete("OnscreenOverlay")
38-
this.OnscreenOverlay.Position[1] := p_name_Obj.Delete("OverlayPos")
39-
this.OnscreenOverlay.ShowOnState := p_name_Obj.Delete("OverlayShow")
40-
this.OnscreenOverlay.Theme := p_name_Obj.Delete("OverlayTheme")
41-
this.OnscreenOverlay.Size := p_name_Obj.Delete("OverlaySize")
42-
this.OnscreenOverlay.UseCustomIcons := p_name_Obj.Delete("OverlayUseCustomIcons")
43-
}
44-
4530
for prop, val in p_name_Obj {
4631
this[prop] := val
4732
}
@@ -51,14 +36,6 @@
5136
; if it's less than 1000, it's most likely an old value
5237
if (A_AfterUpdate && p_name_Obj.afkTimeout < 1000)
5338
this.afkTimeout := p_name_Obj.afkTimeout * 60000
54-
55-
; Ensure compatibility with old versions
56-
if (!IsObject(this.Microphone)) {
57-
this.Microphone := Array(new MicrophoneTemplate(this.Delete("Microphone")
58-
, this.Delete("MuteHotkey")
59-
, this.Delete("UnmuteHotkey")
60-
, this.Delete("PushToTalk")))
61-
}
6239
}
6340
}
6441
}

0 commit comments

Comments
 (0)