zone97 Posted October 2, 2013 Share Posted October 2, 2013 I have a script that creates hot keys for volume change. It works perfectly, except when the mixer changes. IE: if im using the built in sound card then plug in an HDMI cord and the audio changes to the hdmi, I have to close and reopen my script to get it to work again. What I would like is the program to detect when the mixer changes and restart. anyway this can be done? Spoiler WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ] Link to comment Share on other sites More sharing options...
Astormooke Posted October 2, 2013 Share Posted October 2, 2013 (edited) I googled it and got this topic, see if you can find anything useful '?do=embed' frameborder='0' data-embedContent>> Edited October 2, 2013 by Astormooke Link to comment Share on other sites More sharing options...
mrflibblehat Posted October 2, 2013 Share Posted October 2, 2013 (edited) What have you done so far? Could you post your code? Edited October 2, 2013 by mrflibblehat [font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font] Link to comment Share on other sites More sharing options...
zone97 Posted October 3, 2013 Author Share Posted October 3, 2013 Here is my current code. Im sure it could be cleaned up, it was pieced together from others code. expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=icons\volume.ico #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_Res_Comment=OSD Volume Control #AutoIt3Wrapper_Res_Description=VolumeOSD #AutoIt3Wrapper_Res_Fileversion=1.1.0.0 #AutoIt3Wrapper_Res_LegalCopyright=by Erik Pilsits #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_After=del "%scriptdir%\%scriptfile%_Obfuscated.au3" #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <Timers.au3> #include <Misc.au3> #include <WinAPI.au3> #include <StaticConstants.au3> #include <_AudioEndpointVolume.au3> Global $gui, $prog, $label, $th, $show, $timer = -1 Global $transColor = 0x232323 Global $Level Global $msg Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) Opt("TrayOnEventMode", 1) Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 3) Opt("WinWaitDelay", 750) TraySetIcon("icons\volume.ico") TraySetState() TraySetClick(16) TrayCreateItem("Help") TrayItemSetOnEvent(-1, "_Help") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_Exit") HotKeySet("^!1", "Sound1") HotKeySet("^!2", "Sound2") HotKeySet("^!3", "Sound3") HotKeySet("^!4", "Sound4") HotKeySet("^!5", "Sound5") HotKeySet("^!6", "Sound6") HotKeySet("^!7", "Sound7") HotKeySet("^!8", "Sound8") HotKeySet("^!9", "Sound9") HotKeySet("^!0", "_vol_mute") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect Sleep(250) $Level = _GetMasterVolumeLevelScalar() $Level = Round($Level) TraySetToolTip("Quick Volume " & $Level & "%") WEnd Func _vol_mute() _SetMute(Number(Not _GetMute())) If Not _GetMute() Then _SetVolume(_GetMasterVolumeLevelScalar()) EndFunc Func Sound1() Local $vol $vol = 5 _SetVolume($vol) EndFunc Func Sound2() Local $vol $vol = 15 _SetVolume($vol) EndFunc Func Sound3() Local $vol $vol = 24 _SetVolume($vol) EndFunc Func Sound4() Local $vol $vol = 36 _SetVolume($vol) EndFunc Func Sound5() Local $vol $vol = 47 _SetVolume($vol) EndFunc Func Sound6() Local $vol $vol = 60 _SetVolume($vol) EndFunc Func Sound7() Local $vol $vol = 73 _SetVolume($vol) EndFunc Func Sound8() Local $vol $vol = 86 _SetVolume($vol) EndFunc Func Sound9() Local $vol $vol = 99 _SetVolume($vol) EndFunc Func _Help() MsgBox(0,"How To","Usage..." & @CRLF & " " & @CRLF & "CTRL-ALT-1 = 10%" & @CRLF & "CTRL-ALT-3 = 25%" & @CRLF & "CTRL-ALT-5 = 40%" & @CRLF & "CTRL-ALT-7 = 70%" & @CRLF & "CTRL-ALT-9 = 100%" & @CRLF & "CTRL-ALT-0 = Mute") EndFunc Func _Exit() ; FileDelete("*.ico") Exit EndFunc Func _SetVolume($vol) If _GetMute() Then _SetMute(0) EndIf Local $rvol = Round($vol) _SetMasterVolumeLevelScalar($rvol) GUICtrlSetData($prog, $rvol) GUICtrlSetData($label, $rvol) EndFunc Spoiler WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ] Link to comment Share on other sites More sharing options...
BrewManNH Posted October 3, 2013 Share Posted October 3, 2013 That script will never work to do what you want. GUICtrl* functions only work on AutoIt created controls running in the same script. Then you have the option set GUIOnEventMode, but you don't have a GUI. Then you're using GUIGetMsg, which even if you had a GUI wouldn't work because you have OnEvent mode set and you can't use both in the same script at the same time. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now