Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/05/2020 in all areas

  1. Earthshine

    Ping() issue

    Really? I dropped eset ys ago due to all it’s windows issues. It’s garbage. Use windows built-in defender and that’s all you need maybe Malwarebytes in addition
    2 points
  2. Had this code saved from somewhere in the forum, made some tweaks to allow volume to be changed with the keyboard arrows. The only thing you have to give is a processname. Adapt to your needs. #include-once ;https://www.autoitscript.com/forum/topic/174460-is-there-a-way-to-detect-any-sound-file-played/ ;Special Thanks to Danyfirex 02/08/2015 #include <WinAPIProc.au3> #include <Array.au3> #include <Misc.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 Local $PList = ProcessList() _ArrayDisplay($PList) $SoundAPP = InputBox('Process name', 'What is the process name?', 'firefox.exe') Local $CurrentVolume = Audio_GetMasterVolume(_GetProcessID_by_name($SoundAPP)) * 100 Local $Vol = $CurrentVolume MsgBox(64 + 262144, $Vol, $SoundAPP) Local $SMV While 1 If _IsPressed(26) Then ConsoleWrite('UP! ' &$Vol&@CRLF) $Vol = $Vol+1 Audio_SetMasterVolume(_GetProcessID_by_name($SoundAPP), $Vol/ 100) ConsoleWrite('$SMV:'& $SMV&@CRLF) Sleep(10) EndIf If _IsPressed(28) Then ConsoleWrite('DOWN! ' &$Vol&@CRLF) $Vol = $Vol-1 $SMV=Audio_SetMasterVolume(_GetProcessID_by_name($SoundAPP), $Vol/ 100) ConsoleWrite('$SMV:'& $SMV&@CRLF) Sleep(10) EndIf $CurrentVolume = Round(Audio_GetMasterVolume(_GetProcessID_by_name($SoundAPP)) * 100, 0) ConsoleWrite('CV:'&$CurrentVolume &@CRLF) Sleep(100) WEnd Func _GetProcessID_by_name($process_name) Local $Process_list = ProcessList() Local $ProcessID_Func = 0 For $i = 1 To UBound($Process_list) - 1 If $Process_list[$i][0] = $process_name Then $ProcessID_Func = $Process_list[$i][1] ExitLoop EndIf Next Return $ProcessID_Func EndFunc ;==>_SoundAPP_setVolume Func Audio_SetMasterVolume($pid, $value) 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 If $oISimpleAudioVolume.SetMasterVolume($value, 0) >= 0 Then $error = 0 ExitLoop EndIf EndIf EndIf Next EndIf $oISimpleAudioVolume = 0 $oIAudioSessionControl2 = 0 $oIAudioSessionEnumerator = 0 ;MsgBox(0, $error, "App muted: " & $bMute) Return SetError($error, 0, $bMute) EndFunc ;==>Audio_SetMasterVolume Func Audio_GetMasterVolume($pid) 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 If $oISimpleAudioVolume.GetMasterVolume($bMute) >= 0 Then $error = 0 ExitLoop EndIf EndIf EndIf Next EndIf $oISimpleAudioVolume = 0 $oIAudioSessionControl2 = 0 $oIAudioSessionEnumerator = 0 ;MsgBox(0, $error, "App muted: " & $bMute) Return SetError($error, 0, $bMute) EndFunc ;==>Audio_GetMasterVolume 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(__uuidof($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 __uuidof($sGUID) Local $tGUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "struct*", $tGUID) If @error Then Return SetError(@error, @extended, 0) Return $tGUID EndFunc ;==>__uuidof 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 ;==>CLSIDFromString
    2 points
  3. 1 point
  4. That function is present in the include wd_helper.au3 If you use (have copied) that function in your own script too, there will be 2 functions with the same name, therefore, duplicate. In order to call that function you don't need to copy it into your script, you just call it _WD_LinkClickByText($sSession, $sText, True) replacing the variables in there with the variables or values as needed.
    1 point
  5. @Musashi's script works well because it basically traps the flow of the script at any time, meaning you can pause between actions in a function. There are some cases where you may need that the script continues and not be stuck in a loop like that, for those cases you can go with something like this: Global $g_bPaused = 1 HotKeySet("{F2}", "_TogglePause") HotKeySet("{ESC}", "_Terminate") While 1 If $g_bPaused = 0 Then ;Stuff EndIf WEnd Func _TogglePause() If $g_bPaused = 0 Then $g_bPaused = 1 ToolTip('Script is "Paused"', 0, 0) Else $g_bPaused = 0 ToolTip('Script is "Running"', 0, 0) EndIf Sleep(1000) ToolTip("") EndFunc ;==>_TogglePause Func _Terminate() Exit EndFunc ;==>_Terminate It's different in that, the loop keeps going and other things may still work, if you have them in the main loop, but this would not stop in the middle of the action, it would only pause at the end of the actions, i hope i can get the message across, sometimes is difficult to me.
    1 point
  6. in the inputbox you have to put one processname that is currently running, which one did you put in, if any? The default is firefox.exe, do you have firefox running? What is the process name of the application you want to change the volume of?
    1 point
  7. What you need is the silent switches for these programs, and then you do runwait on them. Alternatively, what you could do is the WinWaitClose for the window in question.
    1 point
  8. The Sleep command is independent of the performance of the respective PC. Sleep(1000) has a duration of 1000 ms (1 sec ) on any PC. I therefore do not understand what argues against the use of Sleep in general. Recommendation : It would be beneficial if you could write function names, variable names and comments in English language. This makes it easier for potential helpers to follow your source code. Text output in message boxes or in a GUI can be written in your local language of course . Apart from that, I consider it just like @water .
    1 point
  9. Welcome to AutoIt and the forum! I would use the following approach: Professional programs provide a silent installation option. So there is no need to automate the application's GUI. On the forum you will find ready-made tools to select and install programs (Example: Vollatran). You can easily add new software without the need to modify your autoit script
    1 point
  10. Maybe you're not getting the window handle somehow. how does it work like this? Opt ("WinTitleMatchMode", 3) $appName = "Enter Your Password" WinWait($appName) WinActivate($appName) ConsoleWrite($appName&@CRLF) ControlSetText($appName, "", "[CLASS:Edit; INSTANCE:3]", "This is some text") Sleep(1000) Send("{TAB}") ControlFocus($appName, "", "Edit3") Sleep(1000) Send("Some text", 1) Send("{ENTER}") It's always helpful to place some consolewrites with the variables to see if they are what is expected. I did that with a test application and got all zeroes as the handle, as soon as i ditched the handle, it all works. PS any special reason to use the flag 4 for the OPT?
    1 point
  11. It's a work in progress but it woks 😁 Ever worked with nested arrays before and wanted to see the whole tree structure to examine your array? Now you can! With this handy little UDF: #include <GuiTreeView.au3> #include <GuiConstants.au3> Local $A = [1, 2, 3] Local $B = [['a', 'b', 'c'], ['d', $A, 'f'], ['g', 'h', 'i']] Local $C = [$A, $B] _NestedArrayDisplay($A) _NestedArrayDisplay($B) _NestedArrayDisplay($C) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _NestedArrayDisplay ; Description ...: For viewing nested array's in a treevieuw ; Syntax ........: _NestedArrayDisplay($array) ; Parameters ....: $array (a nested array) ; Return values .: None ; Author ........: TheAutomator ; Modified ......: First UDF, not modified yet ; Remarks .......: Can also display multidimensional array's ; Related .......: _ArrayDisplay ; Link ..........: None ; Example .......: Above this description ; =============================================================================================================================== Func nested($thing, $node) If IsArray($thing) Then Local $inside If UBound($thing, 0) > 1 Then $inside = GUICtrlCreateTreeViewItem('[MULTID. ARRAY]', $node) For $X = 0 To UBound($thing, 1) - 1 For $Y = 0 To UBound($thing, 2) - 1 nested($thing[$X][$Y], $inside) Next Next Else $inside = GUICtrlCreateTreeViewItem('[ARRAY]', $node) For $item In $thing If IsArray($item) Then nested($item, $inside) Else GUICtrlCreateTreeViewItem($item, $inside) EndIf Next EndIf Else GUICtrlCreateTreeViewItem($thing, $node) EndIf EndFunc ;==>nested Func _NestedArrayDisplay($array) Local $temp_gui = GUICreate('Nested Array', 410, 410) Local $treeview = GUICtrlCreateTreeView(5, 5, 400, 400) nested($array, $treeview) GUISetState(@SW_SHOW, $temp_gui) _GUICtrlTreeView_Expand($treeview) While GUIGetMsg() <> $gui_event_close WEnd GUIDelete($temp_gui) EndFunc ;==>_NestedArrayDisplay Enjoy, hope it's useful for you guys! TheAutomator
    1 point
×
×
  • Create New...