Leaderboard
Popular Content
Showing content with the highest reputation on 03/10/2024 in all areas
-
here is a small and funny script to quickly test your CSS file "on the fly" (no need to compile the help), save your CSS file along this script. just run this script while autoit help is open. The script sets the CSS parameters for the pages as you browse them. #include <IE.au3> Global $oIE Global $sMyCSS = FileRead(".\AutoItHelp.css") ; Your custom CSS file _Example() Func _Example() Local $sHelpVersion = "AutoIt Help (v3.3.16.1)" ; get this from the Help window's title bar Local $hWND = WinGetHandle($sHelpVersion) ; handle of the AutoIt Help window If Not WinExists($hWND) Then Return MsgBox(0, 'Help not found', "no AutoIt Help running", 3) $oIE = _IEAttach($hWND, "embedded") ; get reference to the BrowserControl embedded in the Help If @error Then Return MsgBox(0, 'Browser Control error', "problems on attaching Browser Control", 3) ; Set your custom CSS settings _WebBrowser_CSS_Inject($oIE, $sMyCSS) ; get a reference to the browser's window (for event management purpose) Local $oWindow = $oIE.document.parentwindow ; setup an event management Local $Event = ObjEvent($oWindow, "IEEvent_", 'HTMLWindowEvents') While WinExists($hWND) ; stay alive only while the help is running GUIGetMsg() ; just to delay the CPU load WEnd Return MsgBox(0, '', "AutoIt Help closed", 3) EndFunc ;==>_Example ; following function is fired each time the Help page changes Volatile Func IEEvent_onload($oEvent) ; ConsoleWrite("Debug: onload event" & @crlf) _WebBrowser_CSS_Inject($oIE, $sMyCSS) ; ; apply your custom CSS setting to the loaded page EndFunc ;==>IEEvent_onload ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WebBrowser_CSS_Inject ; Description ...: this function creates into the html document a CSS node element with embedded the passed CSS or a link to a CSS ; Syntax ........: _WebBrowser_CSS_Inject(Byref $oIE_Server, $sStylesheet[, $bIsUrl = False]) ; Parameters ....: $oIE_Server - a Webbrowser object reference. ; $sStylesheet - CSS source to be injected into the page (either, a CSS or an URL (a link to a CSS) ; $bIsUrl - [optional] True if above parameter is an URL (a link to a CSS source). Default is False. ; Return values .: A Node Object reference, representing the appended node ; Author ........: Gianni ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _WebBrowser_CSS_Inject(ByRef $oIE_Server, $sStylesheet, $bIsUrl = False) ; Inject css Local $oStyleNode Local $objDocument = $oIE_Server.document ; If $bIsUrl Then ; use the link to load a stylesheet $oStyleNode = $objDocument.createElement('link') ; // Creates <link /> $oStyleNode.type = "text/css" $oStyleNode.rel = 'stylesheet' $oStyleNode.href = $sStylesheet Else ; inject the stylesheet directly $oStyleNode = $objDocument.createElement('style') ; // Creates <style></style> $oStyleNode.type = 'text/css' $oStyleNode.styleSheet.cssText = $sStylesheet ; // Syntax for IE EndIf ; Local $oNode = $objDocument.getElementsByTagName('head').item(0).appendChild($oStyleNode) If $bIsUrl Then ; wait till css has been downloaded Do Sleep(250) ; ConsoleWrite('css: ' & $oNode.ReadyState & @CRLF) ; debug purpose Until $oNode.ReadyState = "loaded" Or $oNode.ReadyState = "complete" EndIf Return $oNode EndFunc ;==>_WebBrowser_CSS_Inject4 points
-
Based on the posts by @Danyfirex and @careca , I created the following example code. If this code is compiled and executed, it shows the results of SetVolume, GetVolume, SetMute and GetMute commands of ISimpleAudioVolume interface. With this, I would consider my problem SOLVED. Thank you everyone for your kind support. Edit: The code was revised to work in uncompiled script. too. ; File name: VolumeControlForProcess_Example.au3 #AutoIt3Wrapper_Outfile=VolumeControlForProcess_Example.exe #include-once #include <WinAPIProc.au3> #include <Array.au3> #include <Misc.au3> #include <Sound.au3> Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $sTagIMMDeviceEnumerator = _ "EnumAudioEndpoints hresult(int;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(int;int;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr)" Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $sTagIMMDevice = _ "Activate hresult(struct*;dword;ptr;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(wstr*);" & _ "GetState hresult(dword*)" Global Const $sIID_IAudioSessionManager2 = "{77aa99a0-1bd6-484f-8bc7-2c654c9a9b6f}" Global Const $sTagIAudioSessionManager = "GetAudioSessionControl hresult(ptr;dword;ptr*);" & _ "GetSimpleAudioVolume hresult(ptr;dword;ptr*);" Global Const $sTagIAudioSessionManager2 = $sTagIAudioSessionManager & "GetSessionEnumerator hresult(ptr*);" & _ "RegisterSessionNotification hresult(ptr);" & _ "UnregisterSessionNotification hresult(ptr);" & _ "RegisterDuckNotification hresult(wstr;ptr);" & _ "UnregisterDuckNotification hresult(ptr)" Global Const $sIID_IAudioSessionEnumerator = "{e2f5bb11-0570-40ca-acdd-3aa01277dee8}" Global Const $sTagIAudioSessionEnumerator = "GetCount hresult(int*);GetSession hresult(int;ptr*)" Global Const $sIID_IAudioSessionControl = "{f4b1a599-7266-4319-a8ca-e70acb11e8cd}" Global Const $sTagIAudioSessionControl = "GetState hresult(int*);GetDisplayName hresult(ptr);" & _ "SetDisplayName hresult(wstr);GetIconPath hresult(ptr);" & _ "SetIconPath hresult(wstr;ptr);GetGroupingParam hresult(ptr*);" & _ "SetGroupingParam hresult(ptr;ptr);RegisterAudioSessionNotification hresult(ptr);" & _ "UnregisterAudioSessionNotification hresult(ptr);" Global Const $sIID_IAudioSessionControl2 = "{bfb7ff88-7239-4fc9-8fa2-07c950be9c6d}" Global Const $sTagIAudioSessionControl2 = $sTagIAudioSessionControl & "GetSessionIdentifier hresult(ptr)" & _ "GetSessionInstanceIdentifier hresult(ptr);" & _ "GetProcessId hresult(dword*);IsSystemSoundsSession hresult();" & _ "SetDuckingPreferences hresult(bool);" ; http://answers.awesomium.com/questions/3398/controlling-the-sound-using-pinvoke-the-volume-mix.html Global Const $sIID_ISimpleAudioVolume = "{87CE5498-68D6-44E5-9215-6DA47EF883D8}" Global Const $sTagISimpleAudioVolume = _ "SetMasterVolume hresult(float;ptr);" & _ "GetMasterVolume hresult(float*);" & _ "SetMute hresult(int;ptr);" & _ "GetMute hresult(int*)" Global $__oIAudioSessionManager2, $gPID = @AutoItPID, $muteState Opt("WinTitleMatchMode", 2) $sFile = "D:\Music\Phone\Pops\Adele - Hello.mp3" ; full path of your mp3 file $aSound = _SoundOpen($sFile) If @error Then MsgBox(0, 'Open Error', "The file cannot be opened.") Exit EndIf ProcessClose("sndvol.exe") Run(@SystemDir &"\sndvol.exe") $hWnd = WinWaitActive(" Mixer - ") Sleep(3000) _SoundPlay($aSound) Sleep(5000) $muteState = _Audio_Action("GetMute", $gPID, "") If $muteState <> 0 Then _Audio_Action("SetMute", $gPID, False) EndIf _Audio_Action("SetVolume", $gPID, 50/100) $iVolume = Round(_Audio_Action("GetVolume", $gPID, "")*100) MsgBox(0, '', "Initial Volume: " & $iVolume) _Audio_Action("SetVolume", $gPID, 100/100) $iVolume = Round(_Audio_Action("GetVolume", $gPID, "")*100) MsgBox(0, '', "Final Volume: " & $iVolume) _Audio_Action("SetMute", $gPID, True) $muteState = _Audio_Action("GetMute", $gPID, "") ; 1 if muted, 0 if unmuted ; 0 if unmuted, 1 if muted via Mixer, -1 if muted via SetMute If $muteState = 0 Then $muteState = "Unmuted" ElseIf $muteState = -1 Then $muteState = "Muted" EndIf MsgBox(0, '', "Result of GetMute Command: " & $muteState) _Audio_Action("SetMute", $gPID, False) $muteState = _Audio_Action("GetMute", $gPID, "") ; 0 if unmuted, 1 if muted via Mixer, -1 if muted via SetMute If $muteState = 0 Then $muteState = "Unmuted" ElseIf $muteState = -1 Then $muteState = "Muted" EndIf MsgBox(0, '', "Result of GetMute Command: " & $muteState) Sleep(5000) _SoundClose($aSound) Func _Audio_Action($action, $pid, $value) ; Each action takes about 6 milliseconds If Not IsObj($__oIAudioSessionManager2) Then $__oIAudioSessionManager2 = Audio_GetIAudioSessionManager2() EndIf If Not IsObj($__oIAudioSessionManager2) Then Return Local $pIAudioSessionEnumerator, $oIAudioSessionEnumerator If $__oIAudioSessionManager2.GetSessionEnumerator($pIAudioSessionEnumerator) < 0 Then Return $oIAudioSessionEnumerator = ObjCreateInterface($pIAudioSessionEnumerator, $sIID_IAudioSessionEnumerator, $sTagIAudioSessionEnumerator) If Not IsObj($oIAudioSessionEnumerator) Then Return SetError(1) Local $i, $nSessions, $pIAudioSessionControl2, $oIAudioSessionControl2 Local $ProcessID, $oISimpleAudioVolume Local $bMute = 0, $error = 1 If $oIAudioSessionEnumerator.GetCount($nSessions) >= 0 Then For $i = 0 To $nSessions - 1 If $oIAudioSessionEnumerator.GetSession($i, $pIAudioSessionControl2) >= 0 Then $oIAudioSessionControl2 = ObjCreateInterface($pIAudioSessionControl2, $sIID_IAudioSessionControl2, $sTagIAudioSessionControl2) If @error Then ContinueLoop $oIAudioSessionControl2.GetProcessId($ProcessID) If $ProcessID = $pid Then $oISimpleAudioVolume = ObjCreateInterface($pIAudioSessionControl2, $sIID_ISimpleAudioVolume, $sTagISimpleAudioVolume) If @error Then ContinueLoop $oIAudioSessionControl2.AddRef() ;stabilize Switch $action Case "SetVolume" If $oISimpleAudioVolume.SetMasterVolume($value, 0) >= 0 Then $error = 0 ExitLoop EndIf Case "GetVolume" If $oISimpleAudioVolume.GetMasterVolume($value) >= 0 Then $error = 0 ExitLoop EndIf Case "SetMute" If $oISimpleAudioVolume.SetMute($value, Null) >= 0 Then $error = 0 ExitLoop EndIf Case "GetMute" If $oISimpleAudioVolume.GetMute($value) >= 0 Then $error = 0 ExitLoop EndIf EndSwitch EndIf EndIf Next EndIf $oISimpleAudioVolume = 0 $oIAudioSessionControl2 = 0 $oIAudioSessionEnumerator = 0 Return SetError($error, 0, $value) EndFunc ;==>_Audio_Action Func Audio_GetIAudioSessionManager2() Local $oIAudioSessionManager2 = 0 Local Const $eMultimedia = 1, $CLSCTX_INPROC_SERVER = 0x01 Local $pIMMDevice, $oMMDevice, $pIAudioSessionManager2 Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $sTagIMMDeviceEnumerator) If IsObj($oMMDeviceEnumerator) Then If $oMMDeviceEnumerator.GetDefaultAudioEndpoint(0, $eMultimedia, $pIMMDevice) >= 0 Then $oMMDevice = ObjCreateInterface($pIMMDevice, $sIID_IMMDevice, $sTagIMMDevice) If IsObj($oMMDevice) Then If $oMMDevice.Activate(_CLSIDFromString($sIID_IAudioSessionManager2), $CLSCTX_INPROC_SERVER, 0, $pIAudioSessionManager2) >= 0 Then $oIAudioSessionManager2 = ObjCreateInterface($pIAudioSessionManager2, $sIID_IAudioSessionManager2, $sTagIAudioSessionManager2) EndIf $oMMDevice = 0 EndIf EndIf $oMMDeviceEnumerator = 0 EndIf If IsObj($oIAudioSessionManager2) Then Return $oIAudioSessionManager2 EndIf EndFunc ;==>Audio_GetIAudioSessionManager2 Func _CLSIDFromString($sGUID) Local $tGUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "struct*", $tGUID) Return $tGUID EndFunc ;==>CLSIDFromString2 points
-
1 point
-
How can I get/set mute state of Windows Volume Mixer?
argumentum reacted to CYCho for a topic
According to my observation, 3 AutoIt3.exe processes are created when I run an uncompiled script. I would conjecture that ProcessList() function lists the processes in chronological order. Out of these 3 processes, I found that the 2nd from the last was the one registered in Windows Volume Mixer. So I revised the code in the previous post so that it works in both compiled and uncompiled scripts. Edit: @AutoItPID macro is the best answer.1 point -
CRACKED IT! I noticed that the output sheet was always 'resting' on K281, which was curious as none of my update/delete operations were around this. I checked my template - which has far more data in it - and, yes, the cursor was sitting on K281. Setting my template to A1 before closing now ripples through - the output sheet also starts up on A1. Still slightly curious to see if there's any OpenCalc function that emulates a click on A1.. but clearly any operations on the Calc spreadsheet using the UDF do not change the selected cell. Excel VBA has a Cells("A1").Select comand to do just that. Anyway, thanks for acting as a sounding board and I hope that this tidbit might help someone else who's, like me, spent days trying to figure it out. John1 point