Leaderboard
Popular Content
Showing content with the highest reputation on 02/21/2020 in all areas
-
Coding Autoit & RESPECT
noellarkin and 2 others reacted to iamtheky for a topic
3 points -
Coding Autoit & RESPECT
noellarkin and 2 others reacted to argumentum for a topic
I tell ppl. I use C++ and add a Boralnd C++ icon. Most ppl have no clue and "C++" sounds like they are smart and are making a good choice using me ...if they wanna dig deeper, I tell'em is a C++ stub I've got, and that speeds my development. Not much is a lie. Then again, I don't fight with egos.3 points -
That isn't a valid command. Perhaps you meant this? GuiCtrlSetData(-1, $NA1 & " |" & $NA2, "")1 point
-
The reason it doesn't change the original inner array is because you never actually modified it. You modify a copy of it, then do absolutely nothing with that modified array expecting it to magically know that the copy of the array is supposed to modify the original array without being told to. Here's how it SHOULD have been written. Also, there's no bug here, it's working exactly as expected. #include <Array.au3> ; a boring old array Local $aInnerArray[5] = [1, 2, 3, 4, 5] ; a one-element array containing a reference to the other array Local $aOuterArray[1] = [$aInnerArray] ; intention: take a nested array and alter its inner array ; reality: the inner array seems to be getting copied Func ChangeIt(ByRef $aOuter) Local $aInner = $aOuter[0] $aInner[2] = 0 $aOuter[0] = $aInner ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Add this line to modify $aOuter EndFunc ; Expected: [1, 2, 3, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✔ _ArrayDisplay($aInnerArray) ; $aOuterArray passed by-ref, should receive reference to $aInnerArray ; Therefore should change $aInnerArray to [1, 2, 0, 4, 5] ChangeIt($aOuterArray) ; Expected: [1, 2, 0, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✘ _ArrayDisplay($aOuterArray[0]) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Change this line because you're showing the ORIGINAL array, and not the contents of the $aOuterArray nested array.1 point
-
I dont know if i got you right but You havent even declared $aOuter ... and you don't wanna change or return it so why you need Byref? if you just change Func ChangeIt(ByRef $aOuter) Local $aInner = $aOuter[0] $aInner[2] = 0 EndFunc with Func ChangeIt(ByRef $aOuter) Local $aInner = $aOuter[0] $aInnerArray[2] = 0 EndFunc it works like you expected... because You just change $aInnerArray[2]. But this would always happen even when you just write $aInnerArray[2] = 0 so what do you exactly want to do? btw yes you can have 1 array which include multiple arrays1 point
-
Trouble with an operator Please change this If $sHour == $eHour Then to this If $sHour = $eHour Then1 point
-
fs1234, You keep calling the function from within itself - hence the recursion fail. I suggest reading the Recursion tutorial in the Wiki to understand why this is usually a bad idea unless you are very careful. And if you require time differences, why not use _DateDiff? M231 point
-
Control *Application* Sound Volume?
Floooooo24 reacted to Aelc for a topic
Here you go - tested with WIN7 and AIMP special thanks goes to DanyfireX for the sounddetect code #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> 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 $SoundAPP = "AIMP.exe" $newValue = Random ( 1,100,1 ) MsgBox ( 64,"","new random value: " & $newValue, 1 ) Local $CurrentVolume = Audio_GetMasterVolume(_GetProcessID_by_name($SoundAPP)) * 100 If $CurrentVolume <> $newValue And $CurrentVolume > $newValue Then For $i = $CurrentVolume To $newValue Step -1 Audio_SetMasterVolume(_GetProcessID_by_name($SoundAPP), $i / 100) Sleep(30) Next Else For $i = $CurrentVolume To $newValue Step +1 Audio_SetMasterVolume(_GetProcessID_by_name($SoundAPP), $i / 100) Sleep(30) Next EndIf 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 Had fun on it so I inserted a fading and it's actually a random value I don't know why but actually SoundSetWaveVolume() doesn't work... So i have to set the Master Volume up to 100 because the device volume compare to it :/ If you want it like the SoundSetWaveVolume() just make a func of it with $soundAPP and $newValue as Parameter and delete that like the msgbox.1 point -
Coding Autoit & RESPECT
noellarkin reacted to FrancescoDiMuro for a topic
@Dana86 Don't listen to them; they're just ignorants because they're judging something (and even worse, someone) by a thing they don't know. AutoIt is a powerful scripting language you can do a lot of amazing things with. I started studying AutoIt back in 2016 for a script which had to run multiple intsances of a program, and move each instance on a different screen; from there, I've never stopped working with AutoIt, and everyday (mostly thanks to the amazing community on the Forums which is envied in other coding Forums), you never stop to learn something new and useful, and the simplicity of the language makes everything more comprehensible and understandable from who had never used a programming language. Be proud of what you do, and don't feel judged by someone who can even understand what is saying. Cheers1 point -
Listview just like Windows Explorer
argumentum reacted to LarsJ for a topic
argumentum, You do the same for selected items. Split Case $iHot, $iSel in the $CDDS_ITEMPOSTPAINT section this way: Case $iHot ; Hot item Return $CDRF_NEWFONT ; Skip this item Case $iSel ; Selected item DllCall( "gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPenSel ) ; _WinAPI_SelectObject For $iSubItem = 0 To 2 ; For each subitem (column) DllStructSetData( $tRect, "Top", $iSubItem ) DllStructSetData( $tRect, "Left", $LVIR_LABEL ) GUICtrlSendMsg( $idListView, $LVM_GETSUBITEMRECT, $iItem, $pRect ) DllCall( "gdi32.dll", "bool", "MoveToEx", "handle", $hDC, "int", DllStructGetData( $tRect, "Right" )-1, "int", DllStructGetData( $tRect, "Top" ), "ptr", 0 ) ; _WinAPI_MoveTo DllCall( "gdi32.dll", "bool", "LineTo", "handle", $hDC, "int", DllStructGetData( $tRect, "Right" )-1, "int", DllStructGetData( $tRect, "Bottom" ) ) ; _WinAPI_LineTo Next Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors Add this line as the very first line in the Case Else section so you can switch between the two pens: DllCall( "gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPen ) ; _WinAPI_SelectObject Create $hPenSel as a Local Static pen of the right color at the top of the WM_NOTIFY function.1 point -
You can pass the variables to C# code this way: tst00.cs using System; class TestClass { public void PassVars( int o_id, object[] i_args, int i_bool ) { Console.WriteLine( "C# code:" ); Console.WriteLine( "o_id = {0}", o_id ); Console.WriteLine( "i_args[0] = {0}", i_args[0] ); Console.WriteLine( "i_args[1] = {0}", i_args[1] ); Console.WriteLine( "i_args[2] = {0}", i_args[2] ); // Convert object to string string sStr = (string) i_args[0]; Console.WriteLine( "sStr = {0}", sStr ); Console.WriteLine( "i_bool = {0}", i_bool ); // Convert variables so that they can be passed to the Connect method. // Execute the Connect method from within the C# code. } } tst00.au3 #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include "DotNetAll.au3" Example() Func Example() Local $oNetCode = DotNet_LoadCScode( FileRead( "tst00.cs" ), "System.dll" ) Local $oTestClass = DotNet_CreateObject( $oNetCode, "TestClass" ) Local $o_id = 111 Local $i_args[3] = ["joe","mike","david"] Local $i_bool = -1 $oTestClass.PassVars( $o_id, $i_args, $i_bool ) EndFunc Console output C# code: o_id = 111 i_args[0] = joe i_args[1] = mike i_args[2] = david sStr = joe i_bool = -11 point