-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PTT function from AHK_MicMute:rewrite (#2)
- Loading branch information
Showing
14 changed files
with
110 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,50 @@ | ||
#Include, <VA> | ||
#Include, <OSD> | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file was deleted.
Oops, something went wrong.