Leaderboard
Popular Content
Showing content with the highest reputation on 08/14/2024 in all areas
-
Or a full interface version : #include <Constants.au3> Opt("MustDeclareVars", True) Interface() Func Interface() Local Const $sTagIDispatch = _ "GetTypeInfoCount hresult(dword*);" & _ "GetTypeInfo hresult(dword;dword;ptr*);" & _ "GetIDsOfNames hresult(struct*;struct*;dword;dword;struct*);" & _ "Invoke hresult(uint;struct*;dword;word;struct*;struct*;ptr;uint*);" Local Const $sCLSID_NetworkListManager = "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}" Local Const $sIID_INetworkListManager = "{DCB00000-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_INetworkListManager = $sTagIDispatch & _ "GetNetworks hresult(int;ptr*);" & _ "GetNetwork hresult(ptr;ptr*)" & _ "GetNetworkConnections hresult(ptr*);" & _ "GetNetworkConnection hresult(ptr;ptr*);" & _ "IsConnectedToInternet hresult(short*);" & _ "IsConnected hresult(short*);" & _ "GetConnectivity hresult(int_ptr*);" & _ "SetSimulatedProfileInfo hresult(struct*);" & _ "ClearSimulatedProfileInfo hresult();" Local Const $sIID_IEnumNetworkConnections = "{DCB00006-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_IEnumNetworkConnections = $sTagIDispatch & _ "NewEnum hresult(ptr*);" & _ "Next hresult(int;ptr*;int*);" & _ "Skip hresult(int);" & _ "Reset hresult();" & _ "Clone hresult(ptr*);" Local Enum $NLM_CONNECTIVITY_DISCONNECTED, $NLM_CONNECTIVITY_IPV4_NOTRAFFIC, $NLM_CONNECTIVITY_IPV6_NOTRAFFIC, _ $NLM_CONNECTIVITY_IPV4_SUBNET = 0x10, $NLM_CONNECTIVITY_IPV4_LOCALNETWORK = 0x20, $NLM_CONNECTIVITY_IPV4_INTERNET = 0x40, _ $NLM_CONNECTIVITY_IPV6_SUBNET = 0x100, $NLM_CONNECTIVITY_IPV6_LOCALNETWORK = 0x200, $NLM_CONNECTIVITY_IPV6_INTERNET = 0x400 Local Const $sIID_INetworkConnection = "{DCB00005-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_INetworkConnection = $sTagIDispatch & _ "GetNetwork hresult(ptr*)" & _ "IsConnectedToInternet hresult(boolean*);" & _ "IsConnected hresult(boolean*);" & _ "GetConnectivity hresult(int*);" & _ "GetConnectionId hresult(clsid*);" & _ "GetAdapterId hresult(clsid*);" & _ "GetDomainType hresult(int*);" Local Enum $NLM_NETWORK_CATEGORY_PUBLIC, $NLM_NETWORK_CATEGORY_PRIVATE, $NLM_NETWORK_CATEGORY_DOMAIN_AUTHENTICATED Local Const $sIID_INetwork = "{DCB00002-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_INetwork = $sTagIDispatch & _ "GetName hresult(wstr*);" & _ "SetName hresult(wstr);" & _ "GetDescription hresult(wstr*);" & _ "SetDescription hresult(wstr);" & _ "GetNetworkId hresult(clsid*);" & _ "GetDomainType hresult(int*);" & _ "GetNetworkConnections hresult(ptr*);" & _ "GetTimeCreatedAndConnected hresult(int*;int*;int*;int*);" & _ "IsConnectedToInternet hresult(boolean*);" & _ "IsConnected hresult(boolean*);" & _ "GetConnectivity hresult(int*);" & _ "GetCategory hresult(int*);" & _ "SetCategory hresult(int);" Local $pNWCs, $iNum, $pConn, $oNWC, $sGUID, $pNet, $oNet, $sName Local $oNLM_INetworkListManager = ObjCreateInterface($sCLSID_NetworkListManager, $sIID_INetworkListManager, $sTag_INetworkListManager) If Not IsObj($oNLM_INetworkListManager) Then Exit MsgBox($MB_OK, "Error", "INetworkListManager") $oNLM_INetworkListManager.GetNetworkConnections($pNWCs) Local $oNWCs = ObjCreateInterface($pNWCs, $sIID_IEnumNetworkConnections, $sTag_IEnumNetworkConnections) If Not IsObj($oNWCs) Then Exit MsgBox($MB_OK, "Error", "IEnumNetworkConnections") While True $oNWCs.Next(1, $pConn, $iNum) If Not $iNum Then ExitLoop $oNWC = ObjCreateInterface($pConn, $sIID_INetworkConnection, $sTag_INetworkConnection) If Not IsObj($oNWC) Then Exit MsgBox($MB_OK, "Error", "INetworkConnection") $oNWC.GetAdapterId($sGUID) ConsoleWrite("GetAdapterId: " & $sGUID & @CRLF) $oNWC.GetNetwork($pNet) $oNet = ObjCreateInterface($pNet, $sIID_INetwork, $sTag_INetwork) If Not IsObj($oNet) Then Exit MsgBox($MB_OK, "Error", "INetwork") $oNet.GetName($sName) ConsoleWrite("GetName: " & $sName & @CRLF) WEnd EndFunc ;==>Interface3 points
-
Problem determining the adapter GUID when using the Network List Manager COM interface
pixelsearch and one other reacted to Danyfirex for a topic
Maybe this; Local Const $tagIDispatch = _ "GetTypeInfoCount hresult(dword*);" & _ "GetTypeInfo hresult(dword;dword;ptr*);" & _ "GetIDsOfNames hresult(struct*;struct*;dword;dword;struct*);" & _ "Invoke hresult(uint;struct*;dword;word;struct*;struct*;ptr;uint*);" Local Const $sIID_INetworkConnection = "{DCB00005-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_INetworkConnection = $tagIDispatch & _ "GetNetwork hresult()" & _ "IsConnectedToInternet hresult();" & _ "IsConnected hresult();" & _ "GetConnectivity hresult();" & _ "GetConnectionId hresult();" & _ "GetAdapterId hresult(clsid*);" & _ "GetDomainType hresult(int*);" Local $oObj = ObjCreate("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}") ;NetworkListManager Local $oConnections = $oObj.GetNetworkConnections() For $oConnection In $oConnections Local $oConnectionCast = ObjCreateInterface($oConnection, $sIID_INetworkConnection, $sTag_INetworkConnection) Local $GUID = "" Local $iDomainType=0 $oConnectionCast.GetAdapterId($GUID) $oConnectionCast.GetDomainType($iDomainType) ConsoleWrite("GetAdapterId: " & $GUID & @CRLF) ConsoleWrite("GetDomainType: " & $iDomainType & @CRLF) ;~ ConsoleWrite($oConnection.GetAdapterId & @CRLF) ;this will not work ;~ ConsoleWrite($oConnection.GetDomainType & @CRLF) ;this will work Next Saludos2 points -
Script with _WinAPI_ReadDirectoryChanges
argumentum reacted to Nine for a topic
Nope, just a bad habit of saving space1 point -
Script with _WinAPI_ReadDirectoryChanges
hudsonhock reacted to Nine for a topic
As per help file : It means this is a blocking function, it will wait forever for a change. But there is a way to make it asynchronous. You would need to use the Overlapped version of it. Search the forum, I believe there is an example of it. ps. made one for the fun of it : #include <Constants.au3> #include <WinAPI.au3> Opt("MustDeclareVars", True) HotKeySet("{ESC}", Terminate) Global Const $WATCH_PATH = "C:\Apps\Temp" Global Const $BUFFER_LENGTH = 4096 Global Const $NOTIFY_FLAGS = BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME) Global $tOverlapped, $hDirectory, $hCompletion, $pCompletion, $pDataBuffer, $hEvent DirectoryChange() Func DirectoryChange() $tOverlapped = DllStructCreate($tagOVERLAPPED) $hEvent = _WinAPI_CreateEvent(0, False, False) $tOverlapped.hEvent = $hEvent $hDirectory = _WinAPI_CreateFileEx($WATCH_PATH, $OPEN_EXISTING, $FILE_LIST_DIRECTORY, _ BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE, $FILE_SHARE_DELETE), _ BitOR($FILE_FLAG_BACKUP_SEMANTICS, $FILE_FLAG_OVERLAPPED)) $hCompletion = DllCallbackRegister(CompletionRoutine, "none", "dword;dword;ptr") $pCompletion = DllCallbackGetPtr($hCompletion) $pDataBuffer = _WinAPI_CreateBuffer($BUFFER_LENGTH) _WinAPI_ReadDirectoryChangesW($hDirectory, $NOTIFY_FLAGS, $pDataBuffer, $BUFFER_LENGTH, True, $tOverlapped, $pCompletion) OnAutoItExitRegister(CleanUp) While True _WinAPI_WaitForSingleObjectEx($hEvent, 0, 1) Sleep(100) WEnd EndFunc ;==>DirectoryChange ;~ Make decisions on file changes in here Func FileNotifyUser($nFileAction, $sFileName) Switch $nFileAction Case $FILE_ACTION_ADDED ConsoleWrite("File added: " & $sFileName & @CRLF) Case $FILE_ACTION_REMOVED ConsoleWrite("File removed: " & $sFileName & @CRLF) Case $FILE_ACTION_RENAMED_OLD_NAME ConsoleWrite("File renamed from: " & $sFileName & @CRLF) Case $FILE_ACTION_RENAMED_NEW_NAME ConsoleWrite("File renamed to: " & $sFileName & @CRLF) EndSwitch EndFunc ;==>FileNotifyUser Func CleanUp() _WinAPI_CancelIoEx($hDirectory, $tOverlapped) _WinAPI_CloseHandle($hDirectory) _WinAPI_FreeMemory($pDataBuffer) _WinAPI_CloseHandle($hEvent) DllCallbackFree($hCompletion) EndFunc ;==>CleanUp Func CompletionRoutine($nError, $nTransfered, $pOverlapped) Local $pBuffer = $pDataBuffer, $tNotify, $nLength While True $nLength = DllStructGetData(DllStructCreate("dword", $pBuffer + 8), 1) $tNotify = DllStructCreate("dword NextOffset;dword Action;dword NameLength;wchar FileName[" & $nLength / 2 & "]", $pBuffer) FileNotifyUser($tNotify.Action, $tNotify.FileName) If Not $tNotify.NextOffset Then ExitLoop $pBuffer += $tNotify.NextOffset WEnd _WinAPI_ReadDirectoryChangesW($hDirectory, $NOTIFY_FLAGS, $pDataBuffer, $BUFFER_LENGTH, 0, $tOverlapped, $pCompletion) EndFunc ;==>CompletionRoutine Func _WinAPI_ReadDirectoryChangesW($hDirectory, $iFilter, $pBuffer, $iLength, $bSubtree = 0, $tOverlapped = 0, $pCompletion = 0) Local $aRet = DllCall('kernel32.dll', 'bool', 'ReadDirectoryChangesW', 'handle', $hDirectory, 'struct*', $pBuffer, _ 'dword', $iLength - Mod($iLength, 4), 'bool', $bSubtree, 'dword', $iFilter, 'dword*', 0, 'struct*', $tOverlapped, 'PTR', $pCompletion) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return SetExtended(_WinAPI_GetLastError(), $aRet[0]) EndFunc ;==>_WinAPI_ReadDirectoryChangesW Func _WinAPI_CancelIoEx($hFile, $tOverlapped) Local $aRet = DllCall('kernel32.dll', 'bool', 'CancelIoEx', 'handle', $hFile, 'struct*', $tOverlapped) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>_WinAPI_CancelIoEx Func _WinAPI_WaitForSingleObjectEx($hEvent, $nMilliseconds, $bAlertable = 0) Local $aRet = DllCall('kernel32.dll', 'dword', 'WaitForSingleObjectEx', 'handle', $hEvent, 'dword', $nMilliseconds, 'bool', $bAlertable) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>_WinAPI_WaitForSingleObjectEx Func Terminate() Exit EndFunc ;==>Terminate1 point -
Problem determining the adapter GUID when using the Network List Manager COM interface
DonChunior reacted to Nine for a topic
The problem is that those objects inherit from IDispatch, you will need to add the methods before, like this : Interface() Func Interface() Local Const $tagIDispatch = _ "GetTypeInfoCount hresult(dword*);" & _ "GetTypeInfo hresult(dword;dword;ptr*);" & _ "GetIDsOfNames hresult(struct*;struct*;dword;dword;struct*);" & _ "Invoke hresult(uint;struct*;dword;word;struct*;struct*;ptr;uint*);" Local Const $sCLSID_NetworkListManager = "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}" Local Const $sIID_INetworkListManager = "{DCB00000-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_INetworkListManager = $tagIDispatch & _ "GetNetworks hresult(int;ptr*);" & _ "GetNetwork hresult(ptr;ptr*)" & _ "GetNetworkConnections hresult(ptr*);" & _ "GetNetworkConnection hresult(ptr;ptr*);" & _ "IsConnectedToInternet hresult(short*);" & _ "IsConnected hresult(short*);" & _ "GetConnectivity hresult(int_ptr*);" & _ "SetSimulatedProfileInfo hresult(struct*);" & _ "ClearSimulatedProfileInfo hresult();" Local $oNLM_INetworkListManager = ObjCreateInterface($sCLSID_NetworkListManager, $sIID_INetworkListManager, $sTag_INetworkListManager) ConsoleWrite(IsObj($oNLM_INetworkListManager) & @CRLF) Local $hResult, $oNWCs $hResult = $oNLM_INetworkListManager.GetNetworkConnections($oNWCs) ConsoleWrite($hResult & "/" & $oNWCs & @CRLF) EndFunc ;==>Interface1 point -
Scheduling an interactive task in AutoIt - (Moved)
rsn reacted to scifigeek64 for a topic
I found the issue. It was all about syntax. I needed to have my variables outside of the single quote for the schtasks. This is what I needed: RunWait("schtasks /create /sc once /TN Scriptfile /SD " & $schdate & " /ST " & $schtime & " /RL HIGHEST /IT /TR c:\users\xxxxx\desktop\apps\Scriptfile.exe") It was really stupid on my part, but at least I finally figured it out. Thanks for the help. Mike1 point -
Run as TrustedInstaller using DLL (NSudoDM.dll, NSudoAPI.dll)
Andreik reacted to argumentum for a topic
ok, ok. I should have run whoami /groups to know if the user in that cmd.exe is part of "NT SERVICE\TrustedInstaller" and in fact is. 💯1 point -
Description: UDF to simply create modern looking GUIs Features: Create light modern aesthetic borderless GUI Interactive menu panel (with mouse-over detection) A bunch of skins (color sets) are available with possibility to create your owns Files: UDF (MTSkin_UDF.au3) + Example Scripts (Example.au3 & Example2.au3) Screenshots: I would be glad to know what you've done with this, so do not hesitate to send me messages. Of course the code can be improved, but I hope you'll find it useful (This is the first time I share my work on this forum, please be indulgent...) Download: MTSkin-UDF.zip Edit: - Scripts modified according to ChuckS' comment - Fixed link broken by reuploading files1 point
-
0 points