gero Posted May 15, 2023 Posted May 15, 2023 I'm doing a project that I need to enable and disable the auxiliary port on the motherboard in Windows 7 or higher on the PC in the case of the blue input above the sound one, I need help to do this. help to do this Teste_Som.au3 controle_volume.au3
Developers Jos Posted May 15, 2023 Developers Posted May 15, 2023 (edited) @gero, This is now the third time you post in the wrong forum, so please pay better attention were you post! Moved to the appropriate AutoIt General Help and Support forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Moderation Team Edited May 15, 2023 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
gero Posted May 15, 2023 Author Posted May 15, 2023 #include <Constants.au3> #include <WinAPI.au3> Global $sHardwareID = "ACPI\PNP0C02\1" ; ID do hardware da porta ACPI Global Const $DICS_ENABLE = 0x0 Global Const $DICS_DISABLE = 0x1 ; Desativa o dispositivo correspondente ao hardware ID Func DisableDevice($sHardwareID) Local $hDevInfo, $i, $tSPDevInfoData, $bResult ; Obtém a lista de dispositivos presentes no sistema $hDevInfo = _WinAPI_SetupDiGetClassDevs($tagGUID_DEVCLASS_SYSTEM, Null, Null, $DIGCF_PRESENT) If $hDevInfo = $INVALID_HANDLE_VALUE Then Return False EndIf ; Procura pelo dispositivo com o hardware ID correspondente $i = 0 Do $tSPDevInfoData = _WinAPI_GetDeviceDataStruct($hDevInfo, $i) If _WinAPI_DevicePropertyString($tSPDevInfoData, $SPDRP_HARDWAREID) = $sHardwareID Then ; Desativa o dispositivo encontrado $bResult = _WinAPI_SetupDiSetDeviceState($hDevInfo, $tSPDevInfoData, $DICS_DISABLE, $DICS_FLAG_GLOBAL) ExitLoop EndIf $i += 1 Until _WinAPI_SetupDiGetDeviceData($hDevInfo, $tSPDevInfoData) _WinAPI_SetupDiDestroyDeviceInfoList($hDevInfo) Return $bResult EndFunc ; Desativa o dispositivo com o hardware ID especificado DisableDevice($sHardwareID)
gero Posted May 15, 2023 Author Posted May 15, 2023 I need help to make it work by disabling and enabling the auxiliary port on the motherboard in Windows 7
Skeletor Posted May 16, 2023 Posted May 16, 2023 expandcollapse popup#include <Constants.au3> #include <WinAPI.au3> Global $sHardwareID = "ACPI\PNP0C02\1" ; ACPI port hardware ID Global Const $DICS_ENABLE = 0x0 Global Const $DICS_DISABLE = 0x1 Func ToggleDeviceState($sHardwareID, $bEnable) Local $hDevInfo, $i, $tSPDevInfoData, $bResult ; Get the list of devices present in the system $hDevInfo = _WinAPI_SetupDiGetClassDevs($tagGUID_DEVCLASS_SYSTEM, Null, Null, $DIGCF_PRESENT) If $hDevInfo = $INVALID_HANDLE_VALUE Then MsgBox($MB_ICONERROR, "Error", "Failed to retrieve device information.") Return False EndIf ; Search for the device with the corresponding hardware ID $i = 0 Do $tSPDevInfoData = _WinAPI_GetDeviceDataStruct($hDevInfo, $i) If _WinAPI_DevicePropertyString($tSPDevInfoData, $SPDRP_HARDWAREID) = $sHardwareID Then ; Enable or disable the device based on the $bEnable flag $bResult = _WinAPI_SetupDiSetDeviceState($hDevInfo, $tSPDevInfoData, $bEnable ? $DICS_ENABLE : $DICS_DISABLE, $DICS_FLAG_GLOBAL) ExitLoop EndIf $i += 1 Until _WinAPI_SetupDiGetDeviceData($hDevInfo, $tSPDevInfoData) _WinAPI_SetupDiDestroyDeviceInfoList($hDevInfo) If Not $bResult Then MsgBox($MB_ICONERROR, "Error", "Failed to change device state.") EndIf Return $bResult EndFunc ; Disable the device with the specified hardware ID If ToggleDeviceState($sHardwareID, False) Then MsgBox($MB_INFORMATION, "Success", "Device disabled successfully.") Else MsgBox($MB_ICONERROR, "Error", "Failed to disable the device.") EndIf ; Enable the device with the specified hardware ID If ToggleDeviceState($sHardwareID, True) Then MsgBox($MB_INFORMATION, "Success", "Device enabled successfully.") Else MsgBox($MB_ICONERROR, "Error", "Failed to enable the device.") EndIf I have not tested it, and disabling or modifying hardware devices is very bad. Proceed at your own risk. Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI
gero Posted May 17, 2023 Author Posted May 17, 2023 I got a way to increase the volume here, I need to do the same thing with the auxiliary sound output because I'm going to use a bluetooth there and I need to decrease the sound or disable the port #include <WinAPI.au3> #include <WindowsConstants.au3> #include <controle_volume.au3> ;############## Controla Volume Inicio ############## ; Caminho para o arquivo nircmd.exe Local $nircmd = _nircmd(True) ; Obter o volume atual $volume_atual = Run($nircmd & " changesysvolume 0") ; Verificar se o volume é diferente de 65535 -> (volume máximo 100%) If $volume_atual <> 64882 Then ;64882 equivale ao volume "99" GetAuxiliaryPortVolume() EndIf Func GetAuxiliaryPortVolume() ; Aumentar o volume para 100% Run($nircmd & " setsysvolume " & Int(65883)) ;Ajusta o volume para 99 EndFunc ;==>Aumenta_Volume controle_volume.au3
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