diff --git a/Lib/OSD.ahk b/Lib/OSD.ahk
index 24475c8..685c8b6 100644
--- a/Lib/OSD.ahk
+++ b/Lib/OSD.ahk
@@ -1,13 +1,15 @@
Global OSD_state:= 0
Global OSD_txt:=
+Global OSD_sysTheme:=
+OSD_getSysTheme()
OSD_spawn(txt, OSD_Accent, exclude_fullscreen:=0){
if (exclude_fullscreen && isActiveWinFullscreen())
return
if (OSD_state = 0){
SetFormat, integer, d
- Gui, Color, 191919, %OSD_Accent%
+ Gui, Color,% OSD_sysTheme? "E6E6E6":"191919" , OSD_Accent
Gui, +AlwaysOnTop -SysMenu +ToolWindow -caption -Border
- Gui, Font, s11, Segoe UI
+ Gui, Font, s11 w500, Segoe UI
Gui, Add, Text, c%OSD_Accent% vOSD_txt W165 Center, %txt%
SysGet, MonitorWorkArea, MonitorWorkArea, 0
OSD_yPos:= MonitorWorkAreaBottom * 0.95
@@ -23,6 +25,10 @@ OSD_destroy(){
OSD_state := 0
SetTimer, OSD_destroy, Off
}
+OSD_getSysTheme(){
+ RegRead, OSD_sysTheme
+ , HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize, SystemUsesLightTheme
+}
isActiveWinFullscreen(){ ;returns true if the active window is fullscreen
winID := WinExist( "A" )
if ( !winID )
diff --git a/MicMute.ahk b/MicMute.ahk
index 0f3cef1..5de4676 100644
--- a/MicMute.ahk
+++ b/MicMute.ahk
@@ -1,81 +1,50 @@
#Include,
#Include,
-OSD_spawn("Loading config...", "4BB04F")
-#Include, resources.ahk
+#Include, config.ahk
+#Include, assets.ahk
+OSD_spawn("MicMute", "4BB04F")
global global_mute:= ;1 muted
+global keys:= StrSplit(hotkey_mute, [" ","#","!","^","+","&",">","<","*","~","$","UP"], " `t")
init_tray()
update_state()
if (sys_update){
SetTimer, update_state, 500
}
if (hotkey_mute=hotkey_unmute){
- Hotkey, %hotkey_mute%, toggle_hotkey
+ Hotkey,%hotkey_mute% ,% push_to_talk? "ptt_hotkey" : "toggle_hotkey"
}else{
Hotkey, %hotkey_mute%, mute_hotkey
Hotkey, %hotkey_unmute%, unmute_hotkey
}
;Hotkey Functions
toggle_hotkey(){
- VA_SetMasterMute(!global_mute, device_name . ":1")
+ VA_SetMasterMute(!global_mute, device_name)
update_state()
- show_feedback(global_mute)
+ show_feedback(global_mute, sound_feedback, OSD_feedback)
+}
+ptt_hotkey(){
+ unmute_hotkey()
+ KeyWait, % keys[keys.Length()]
+ mute_hotkey()
}
mute_hotkey(){
if (global_mute)
return
- VA_SetMasterMute(1, device_name . ":1")
+ VA_SetMasterMute(1, device_name)
update_state()
- show_feedback(global_mute)
+ show_feedback(global_mute, sound_feedback, OSD_feedback)
}
unmute_hotkey(){
if (!global_mute)
return
- VA_SetMasterMute(0, device_name . ":1")
+ VA_SetMasterMute(0, device_name)
update_state()
- show_feedback(global_mute)
+ show_feedback(global_mute, sound_feedback, OSD_feedback)
}
-;
update_state(){
- state:=VA_GetMasterMute(device_name . ":1")
+ state:=VA_GetMasterMute(device_name)
if (state!=global_mute){
global_mute:=state
update_tray(global_mute)
}
-}
-update_tray(state){
- Menu, Tray, Icon, % state? mute_ico : default_ico
- Menu, Tray, Tip, % state? "Microphone Muted" : "Microphone Online"
-}
-show_feedback(state){
- if (sound_feedback){
- SoundPlay,% state? "resources\mute.mp3" : "resources\unmute.mp3"
- }
- if (OSD_feedback){
- OSD_destroy()
- if (state)
- OSD_spawn("Microphone Muted", "DC3545", exclude_fullscreen)
- else
- OSD_spawn("Microphone Online", "007BFF", exclude_fullscreen)
- }
-}
-;tray initialization functions
-init_tray(){
- RegRead, sysTheme
- , HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize, SystemUsesLightTheme
- default_ico:= sysTheme? "resources\default_black.ico" : "resources\default_white.ico"
- mute_ico:= sysTheme? "resources\mute_black.ico" : "resources\mute_white.ico"
- if (FileExist(default_ico)) {
- Menu, Tray, Icon, %default_ico%
- }
- Menu, Tray, Tip, MicMute
- Menu, Tray, NoStandard
- Menu, Tray, Add, Edit Config, edit_config
- Menu, Tray, Add, Help, launch_help
- Menu, Tray, Add, Exit, exit
-}
-launch_help(){
- Run, https://github.com/SaifAqqad/AHK_MicMute#usage
-}
-exit(){
- ExitApp
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 4a9852c..998b622 100644
--- a/README.md
+++ b/README.md
@@ -6,12 +6,13 @@
## Usage
-A config file will open the first time you run the application:
+A config file will be created the first time you run the Script:
```ini
[settings]
Microphone=""
MuteHotkey=""
UnmuteHotkey=""
+PushToTalk=
SoundFeedback=
OnscreenFeedback=
ExcludeFullscreen=
@@ -21,25 +22,30 @@ UpdateWithSystem=
1. `Microphone` can be any substring of your microphone's name or the controller's name as shown in this image:
image
- ![](./resources/Controlpaneldialog.png)
+ ![](./assets/Controlpaneldialog.png)
-
+
+ you can also leave it as `""` to select the default microphone
###
2. Both `MuteHotkey` and `UnmuteHotkey` can be any hotkey supported by AHK, use this [List of keys](https://www.autohotkey.com/docs/KeyList.htm) as a reference, you can also combine them with [hotkey modifiers](https://www.autohotkey.com/docs/Hotkeys.htm#Symbols).
+ You can set both to the same hotkey to make it a toggle.
+
+
Examples: `"<^M"`: left ctrl+M, `"RShift"`: right shift, `"^!T"`: ctrl+alt+T, `"LControl & XButton1"`: left ctrl+ mouse 4
- Note: If both are set to the same hotkey, it will act as a toggle
-3. Both `SoundFeedback` and `OnscreenFeedback` can be set to either `0` or `1`, you can also set `ExcludeFullscreen` to 1 to stop the OSD from showing on top of fullscreen applications
+3. Set `PushToTalk` to `1` to enable PTT, `MuteHotkey` and `UnmuteHotkey` need to be set to the same hotkey first.
+
+4. Both `SoundFeedback` and `OnscreenFeedback` can be set to either `0` or `1`, you can also set `ExcludeFullscreen` to 1 to stop the OSD from showing on top of fullscreen applications
On screen feedback
- ![](./resources/OSD.gif)
+ ![](./assets/OSD.gif)
-4. If `UpdateWithSystem` is set to 1, the tray icon will update whenever the microphone is muted/unmuted by the OS or other applications, it increases CPU usage by 1% at most
+5. If `UpdateWithSystem` is set to 1, the tray icon will update whenever the microphone is muted/unmuted by the OS or other applications, it increases CPU usage by 1% at most
###
@@ -50,6 +56,7 @@ UpdateWithSystem=
Microphone="amazonbasics"
MuteHotkey="*RShift"
UnmuteHotkey="*RShift"
+PushToTalk=0
SoundFeedback=1
OnscreenFeedback=1
ExcludeFullscreen=0
diff --git a/assets.ahk b/assets.ahk
new file mode 100644
index 0000000..ed2da1e
--- /dev/null
+++ b/assets.ahk
@@ -0,0 +1,43 @@
+FileCreateDir, assets
+FileInstall, .\assets\mute.mp3, assets\mute.mp3
+FileInstall, .\assets\unmute.mp3, assets\unmute.mp3
+FileInstall, .\assets\default_white.ico, assets\default_white.ico
+FileInstall, .\assets\default_black.ico, assets\default_black.ico
+FileInstall, .\assets\mute_white.ico, assets\mute_white.ico
+FileInstall, .\assets\mute_black.ico, assets\mute_black.ico
+show_feedback(state, sound_feedback:=0, OSD_feedback:=0){
+ if (sound_feedback){
+ SoundPlay,% state? "assets\mute.mp3" : "assets\unmute.mp3"
+ }
+ if (OSD_feedback){
+ OSD_destroy()
+ if (state)
+ OSD_spawn("Microphone Muted", "DC3545", exclude_fullscreen)
+ else
+ OSD_spawn("Microphone Online", "007BFF", exclude_fullscreen)
+ }
+}
+update_tray(state){
+ Menu, Tray, Icon, % state? mute_ico : default_ico
+ Menu, Tray, Tip, % state? "Microphone Muted" : "Microphone Online"
+}
+init_tray(){
+ RegRead, sysTheme
+ , HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize, SystemUsesLightTheme
+ default_ico:= sysTheme? "assets\default_black.ico" : "assets\default_white.ico"
+ mute_ico:= sysTheme? "assets\mute_black.ico" : "assets\mute_white.ico"
+ if (FileExist(default_ico)) {
+ Menu, Tray, Icon, %default_ico%
+ }
+ Menu, Tray, Tip, MicMute
+ Menu, Tray, NoStandard
+ Menu, Tray, Add, Edit Config, edit_config
+ Menu, Tray, Add, Help, launch_help
+ Menu, Tray, Add, Exit, exit
+}
+launch_help(){
+ Run, https://github.com/SaifAqqad/AHK_MicMute#usage
+}
+exit(){
+ ExitApp
+}
\ No newline at end of file
diff --git a/resources/Controlpaneldialog.png b/assets/Controlpaneldialog.png
similarity index 100%
rename from resources/Controlpaneldialog.png
rename to assets/Controlpaneldialog.png
diff --git a/resources/OSD.gif b/assets/OSD.gif
similarity index 100%
rename from resources/OSD.gif
rename to assets/OSD.gif
diff --git a/resources/default_black.ico b/assets/default_black.ico
similarity index 100%
rename from resources/default_black.ico
rename to assets/default_black.ico
diff --git a/resources/default_white.ico b/assets/default_white.ico
similarity index 100%
rename from resources/default_white.ico
rename to assets/default_white.ico
diff --git a/resources/mute.mp3 b/assets/mute.mp3
similarity index 100%
rename from resources/mute.mp3
rename to assets/mute.mp3
diff --git a/resources/mute_black.ico b/assets/mute_black.ico
similarity index 100%
rename from resources/mute_black.ico
rename to assets/mute_black.ico
diff --git a/resources/mute_white.ico b/assets/mute_white.ico
similarity index 100%
rename from resources/mute_white.ico
rename to assets/mute_white.ico
diff --git a/resources/unmute.mp3 b/assets/unmute.mp3
similarity index 100%
rename from resources/unmute.mp3
rename to assets/unmute.mp3
diff --git a/config.ahk b/config.ahk
new file mode 100644
index 0000000..b925132
--- /dev/null
+++ b/config.ahk
@@ -0,0 +1,28 @@
+if (!FileExist("config.ini") || isFileEmpty("config.ini")) {
+ IniWrite, Microphone=""`nMuteHotkey=""`nUnmuteHotkey=""`nPushToTalk=`nSoundFeedback=`nOnscreenFeedback=`nExcludeFullscreen=`nUpdateWithSystem=`n, config.ini, settings
+ edit_config()
+}
+global device_name:="", global hotkey_mute:="", global hotkey_unmute:="", global push_to_talk:=""
+global sound_feedback:="", global OSD_feedback:=""
+global exclude_fullscreen:="", global sys_update:=""
+global mute_ico:="", global default_ico:=""
+IniRead, device_name, config.ini, settings, Microphone, %A_Space%
+IniRead, hotkey_mute, config.ini, settings, MuteHotkey, %A_Space%
+IniRead, hotkey_unmute, config.ini, settings, UnmuteHotkey, %A_Space%
+IniRead, push_to_talk, config.ini, settings, PushToTalk, 0
+IniRead, sound_feedback, config.ini, settings, SoundFeedback, 0
+IniRead, OSD_feedback, config.ini, settings, OnscreenFeedback, 0
+IniRead, exclude_fullscreen, config.ini, settings, ExcludeFullscreen, 0
+IniRead, sys_update, config.ini, settings, UpdateWithSystem, 0
+if (!device_name)
+ device_name:="capture"
+if (!hotkey_mute or !hotkey_unmute)
+ edit_config()
+edit_config(){
+ RunWait, notepad config.ini
+ Reload
+}
+isFileEmpty(file){
+ FileGetSize, size , %file%
+ return !size
+}
\ No newline at end of file
diff --git a/resources.ahk b/resources.ahk
deleted file mode 100644
index 0cbb98e..0000000
--- a/resources.ahk
+++ /dev/null
@@ -1,36 +0,0 @@
-FileCreateDir, resources
-FileInstall, .\resources\mute.mp3, resources\mute.mp3
-FileInstall, .\resources\unmute.mp3, resources\unmute.mp3
-FileInstall, .\resources\default_white.ico, resources\default_white.ico
-FileInstall, .\resources\default_black.ico, resources\default_black.ico
-FileInstall, .\resources\mute_white.ico, resources\mute_white.ico
-FileInstall, .\resources\mute_black.ico, resources\mute_black.ico
-global device_name:="", global hotkey_mute:="", global hotkey_unmute:=""
-global sound_feedback:="", global OSD_feedback:=""
-global exclude_fullscreen:="", global sys_update:=""
-global mute_ico:="", global default_ico:=""
-if (!FileExist("config.ini") || isFileEmpty("config.ini")) {
- IniWrite, Microphone=""`nMuteHotkey=""`nUnmuteHotkey=""`nSoundFeedback=`nOnscreenFeedback=`nExcludeFullscreen=`nUpdateWithSystem=`n, config.ini, settings
- edit_config()
-}
-load_config()
-load_config(){
- IniRead, device_name, config.ini, settings, Microphone, %A_Space%
- IniRead, hotkey_mute, config.ini, settings, MuteHotkey, %A_Space%
- IniRead, hotkey_unmute, config.ini, settings, UnmuteHotkey, %A_Space%
- IniRead, sound_feedback, config.ini, settings, SoundFeedback, %A_Space%
- IniRead, OSD_feedback, config.ini, settings, OnscreenFeedback, %A_Space%
- IniRead, exclude_fullscreen, config.ini, settings, ExcludeFullscreen, %A_Space%
- IniRead, sys_update, config.ini, settings, UpdateWithSystem, %A_Space%
- if (!device_name or !hotkey_mute or !hotkey_unmute or sound_feedback=""
- or OSD_feedback="" or exclude_fullscreen="" or sys_update="")
- edit_config()
-}
-edit_config(){
- RunWait, config.ini
- Reload
-}
-isFileEmpty(file){
- FileGetSize, size , %file%
- return !size
-}
\ No newline at end of file