Leaderboard
Popular Content
Showing content with the highest reputation on 06/18/2013 in all areas
-
CPU Multi-Processor Usage This is an example of getting and displaying processor usage for all processors in a system. It uses the 'undocumented' NtQuerySystemInformation function to gather processor usage information and then does calculations based on the delta of two readings. I wrote this as an alternative to using my >Performance Counters UDF - specifically, check out >Example # 4: System CPU Usage (by Processor). There is now a new interface, as well as two ways to track CPU usage. The first method tracks usage for all CPU's, and additionally produces an overall CPU usage result. The second method tracks Overall CPU usage - a combined value representing all cores as one unit. Note that this second method uses GetSystemTimes, which requires Windows XP SP1 or higher. The usage works like this for all CPU's: $aCPUsUsageTracker = _CPUsUsageTracker_Create() $iTotalCPUs = $aCPUsUsageTracker[0][0] ; Call the following repeatedly - $aCPUsUsageTracker will be updated automatically: $aPercents = _CPUsUsageTracker_GetUsage($aCPUsUsageTracker) For Overall CPU usage, either look at $aPercents[$iTotalCPUs] above, or use this interface (reliant on GetSystemTimes): $aCPUOverallTracker = _CPUOverallUsageTracker_Create() ; Call the following repeatedly - $aCPUOverallTracker will be updated automatically: $fUsage = _CPUOverallUsageTracker_GetUsage($aCPUOverallTracker) _ Need to see how CPU usage is affected? A simple tool I use to stress-test individual CPU cores is Stress Prime 2004, which can be run multiple times. P.S. All I ask is that you acknowledge me in some way if you use any of this code. updates: 2013-08-31: - Added a simple Overall and Idle CPU usage example 2013-06-18: - Changed interface for getting CPU usage. Now there's no need to juggle arrays around [obsolete version]: - fixed bound check in _CPUCalculateUsages() to look at 2nd dimension CPU_ProcessorUsage.au3 (prev downloads: ~15) ; ======================================================================================================== ; <CPU_ProcessorUsage.au3> ; ; Example of an alternative means to read individual CPU Usages for multiple CPUs, ; along with the combined overall CPU usage. (Alternative to Performance Counters) ; Readings are shown in a 'Splash' window ; ; Functions: ; _CPUGetTotalProcessorTimes() ; Gets Overall (combined CPUs) Processor Times ; _CPUGetIndividualProcessorTimes() ; Returns an array of CPU usage info for individual processors ; _CPUsUsageTracker_Create() ; Creates a CPU usage tracker for all CPUs ; _CPUsUsageTracker_GetUsage() ; Updates CPU usage tracker and returns a CPU usage array ; _CPUOverallUsageTracker_Create() ; Creates a CPU usage tracker for Overall CPU usage ; _CPUOverallUsageTracker_GetUsage(); Updates CPU usage tracker and returns CPU usage [Overall Usage] ; ; See also: ; Performance Counters UDF ; ; ; Author: Ascend4nt ; ======================================================================================================== ; -------------------- HOTKEY FUNCTION & VARIABLE -------------------- Global $bHotKeyPressed=False Func _EscPressed() $bHotKeyPressed=True EndFunc ; ============================================================================================== ; Func _CPUGetTotalProcessorTimes() ; ; Gets the total (combined CPUs) system processor times (as FILETIME) ; Note that Kernel Mode time includes Idle Mode time, so a proper calculation of usage time is ; Kernel + User - Idle ; And percentage (based on two readings): ; (Kernel_b - Kernel_a) + (User_b - User_a) - (Idle_b - Idle_a) * 100 ; / (Kernel_b - Kernal_a) + (User_b - User_a) ; ; O/S Requirements: min. Windows XP SP1+ ; ; Returns: ; Success: Array of info for total (combined CPU's) processor times: ; [0] = Idle Mode Time ; [1] = Kernel Mode Time -> NOTE This INCLUDES Idle Time ; [2] = User Mode Time ; ; Failure: "" with @error set: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: API call returned False - call GetLastError for more info ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUGetTotalProcessorTimes() Local $aRet, $stSystemTimes $stSystemTimes = DllStructCreate("int64 IdleTime;int64 KernelTime;int64 UserTime;") $aRet = DllCall("kernel32.dll", "bool", "GetSystemTimes", "ptr", DllStructGetPtr($stSystemTimes, 1), _ "ptr", DllStructGetPtr($stSystemTimes, 2), "ptr", DllStructGetPtr($stSystemTimes, 3) ) If @error Then Return SetError(2, @error, "") If Not $aRet[0] Then Return SetError(3, 0, "") Dim $aRet[3] = [ _ DllStructGetData($stSystemTimes, 1), _ DllStructGetData($stSystemTimes, 2), _ DllStructGetData($stSystemTimes, 3) ] Return $aRet EndFunc ; ============================================================================================== ; Func _CPUGetIndividualProcessorTimes() ; ; Gets an array of system processor times (as FILETIME) ; Note that Kernel Mode time includes Idle Mode time, so a proper calculation of usage time is ; Kernel + User - Idle ; And percentage (based on two readings): ; (Kernel_b - Kernel_a) + (User_b - User_a) - (Idle_b - Idle_a) * 100 ; / (Kernel_b - Kernal_a) + (User_b - User_a) ; ; Returns: ; Success: 2 Dimensional Array of info [@extended = #of CPU's]: ; [0][0] = # of CPUs (and array elements) ; [1..n][0] = Idle Mode Time for CPU # n ; [1..n][1] = Kernel Mode Time for CPU # n -> NOTE This INCLUDES Idle Time ; [1..n][2] = User Mode Time for CPU # n ; ; Failure: "" with @error set: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: NTSTATUS returned error code, @extended contains error code ; @error = 4: Invalid length returned, @extended is length ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUGetIndividualProcessorTimes() ; DPC = Deferred Procedure Calls Local $tagSYSTEM_PROCESSOR_TIMES = "int64 IdleTime;int64 KernelTime;int64 UserTime;int64 DpcTime;int64 InterruptTime;ulong InterruptCount;" Local $aRet, $stProcessorTimes, $stBuffer Local $i, $nTotalCPUStructs, $pStructPtr ; 256 [maximum CPU's] * 48 (structure size) = 12288 $stBuffer = DllStructCreate("byte Buffer[12288];") ; SystemProcessorTimes = 8 Local $aRet=DllCall("ntdll.dll", "long", "NtQuerySystemInformation", "int", 8, "ptr", DllStructGetPtr($stBuffer), "ulong", 12288, "ulong*", 0) If @error Then Return SetError(2, @error, "") ; NTSTATUS of something OTHER than success? If $aRet[0] Then Return SetError(3, $aRet[0], "") ; Length invalid? If $aRet[4] = 0 Or $aRet[0] > 12288 Or Mod($aRet[4], 48) <> 0 Then Return SetError(4, $aRet[4], "") $nTotalCPUStructs = $aRet[4] / 48 ;~ ConsoleWrite("Returned buffer length = " & $aRet[4] & ", len/48 (struct size) = "& $nTotalCPUStructs & @CRLF) ; We are interested in Idle, Kernel, and User Times (3) Dim $aRet[$nTotalCPUStructs + 1][3] $aRet[0][0] = $nTotalCPUStructs ; Traversal Pointer for individual CPU structs $pStructPtr = DllStructGetPtr($stBuffer) For $i = 1 To $nTotalCPUStructs $stProcessorTimes = DllStructCreate($tagSYSTEM_PROCESSOR_TIMES, $pStructPtr) $aRet[$i][0] = DllStructGetData($stProcessorTimes, "IdleTime") $aRet[$i][1] = DllStructGetData($stProcessorTimes, "KernelTime") $aRet[$i][2] = DllStructGetData($stProcessorTimes, "UserTime") ; Next CPU structure $pStructPtr += 48 Next Return SetExtended($nTotalCPUStructs, $aRet) EndFunc ; ============================================================================================== ; Func _CPUsUsageTracker_Create() ; ; Creates a CPU usage tracker array for all processors. This array should be passed ; to _CPUsUsageTracker_GetUsage() to get current usage information back. ; ; Returns: ; Success: An array used to track CPU usage [@extended = # of CPU's] ; Array 'internal' format: ; $arr[0][0] = # of CPU's ; $arr[1..n][0] = Total CPU Time (Kernel + User Mode) ; $arr[1..n][1] = Total Active CPU Time (Kernel + User - Idle) ; ; Failure: "" with @error set [reflects _CPUGetIndividualProcessorTimes codes]: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: NTSTATUS returned error code, @extended contains error code ; @error = 4: Invalid length returned, @extended is length ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUsUsageTracker_Create() Local $nTotalCPUs, $aCPUTimes, $aCPUsUsage $aCPUTimes = _CPUGetIndividualProcessorTimes() If @error Then Return SetError(@error, @extended, "") $nTotalCPUs = @extended Dim $aCPUsUsage[$nTotalCPUs + 1][2] $aCPUsUsage[0][0] = $nTotalCPUs For $i = 1 To $nTotalCPUs ; Total $aCPUsUsage[$i][0] = $aCPUTimes[$i][1] + $aCPUTimes[$i][2] ; TotalActive (Kernel Time includes Idle time, so we need to subtract that) $aCPUsUsage[$i][1] = $aCPUTimes[$i][1] + $aCPUTimes[$i][2] - $aCPUTimes[$i][0] Next Return SetExtended($nTotalCPUs, $aCPUsUsage) EndFunc ; ============================================================================================== ; Func _CPUOverallUsageTracker_Create() ; ; Creates a CPU usage tracker array for Overall combined processors usage. ; This array should be passed to _CPUOverallUsageTracker_GetUsage() to get ; current usage information. ; ; Returns: ; Success: An array used to track Overall CPU usage ; Array 'internal' format: ; $arr[0] = Total Overall CPU Time (Kernel + User Mode) ; $arr[1] = Total Active Overall CPU Time (Kernel + User - Idle) ; ; Failure: "" with @error set [reflects _CPUGetTotalProcessorTimes codes]: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: API call returned False - call GetLastError for more info ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUOverallUsageTracker_Create() Local $aCPUTimes, $aCPUsUsage[2] $aCPUTimes = _CPUGetTotalProcessorTimes() If @error Then Return SetError(@error, @extended, "") ; Total $aCPUsUsage[0] = $aCPUTimes[1] + $aCPUTimes[2] ; TotalActive (Kernel Time includes Idle time, so we need to subtract that) $aCPUsUsage[1] = $aCPUTimes[1] + $aCPUTimes[2] - $aCPUTimes[0] Return $aCPUsUsage EndFunc ; ============================================================================================== ; Func _CPUsUsageTracker_GetUsage(ByRef $aCPUsUsage) ; ; Updates a CPUsUsage array and returns an array of CPU Usage information for all processors. ; ; Returns: ; Success: Array of CPU Usage -> 1 for each processor + 1 for Overall [@extended = # of processors] ; [0..n] = CPU Usage (Percentage) ; [#CPUs] = CPUs Overall Usage (Percentage) ; Failure: "" with @error set to 1 for invalid parameters, or: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: NTSTATUS returned error code, @extended contains error code ; @error = 4: Invalid length returned, @extended is length ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUsUsageTracker_GetUsage(ByRef $aCPUsUsage) If Not IsArray($aCPUsUsage) Or UBound($aCPUsUsage, 2) < 2 Then Return SetError(1, 0, "") Local $nTotalCPUs, $aUsage, $aCPUsCurInfo Local $nTotalActive, $nTotal Local $nOverallActive, $nOverallTotal $aCPUsCurInfo = _CPUsUsageTracker_Create() If @error Then Return SetError(@error, @extended, "") $nTotalCPUs = $aCPUsCurInfo[0][0] Dim $aUsage[$nTotalCPUs + 1] $nOverallActive = 0 $nOverallTotal = 0 For $i = 1 To $nTotalCPUs $nTotal = $aCPUsCurInfo[$i][0] - $aCPUsUsage[$i][0] $nTotalActive = $aCPUsCurInfo[$i][1] - $aCPUsUsage[$i][1] $aUsage[$i - 1] = Round($nTotalActive * 100 / $nTotal, 1) $nOverallActive += $nTotalActive $nOverallTotal += $nTotal Next $aUsage[$nTotalCPUs] = Round( ($nOverallActive / $nTotalCPUs) * 100 / ($nOverallTotal / $nTotalCPUs), 1) ; Replace current usage tracker info $aCPUsUsage = $aCPUsCurInfo Return SetExtended($nTotalCPUs, $aUsage) EndFunc ; ============================================================================================== ; Func _CPUOverallUsageTracker_GetUsage(ByRef $aCPUsUsage) ; ; Updates a CPUsUsage array and returns CPU Usage information [Overall processor usage] ; ; Returns: ; Success: CPU Usage (Percentage) ; Failure: 0 with @error set to 1 for invalid parameters, or: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: API call returned False - call GetLastError for more info ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUOverallUsageTracker_GetUsage(ByRef $aCPUsUsage) If Not IsArray($aCPUsUsage) Or UBound($aCPUsUsage) < 2 Then Return SetError(1, 0, "") Local $aCPUsCurInfo, $fUsage, $nTotalActive, $nTotal $aCPUsCurInfo = _CPUOverallUsageTracker_Create() If @error Then Return SetError(@error, @extended, 0) $nTotal = $aCPUsCurInfo[0] - $aCPUsUsage[0] $nTotalActive = $aCPUsCurInfo[1] - $aCPUsUsage[1] ; Replace current usage tracker info $aCPUsUsage = $aCPUsCurInfo Return Round($nTotalActive * 100 / $nTotal, 1) EndFunc ; -------------------- MAIN PROGRAM CODE -------------------- HotKeySet("{Esc}", "_EscPressed") Local $hSplash, $sSplashText ; CPU Usage for all CPU's Local $iTotalCPUs, $aCPUsUsageTracker, $aPercents ; Overall CPU Usage Tracker ; (GetSystemTimes) ;~ Local $aCPUOverallTracker ; CPUs Usage Tracker $aCPUsUsageTracker = _CPUsUsageTracker_Create() If @error Then Exit ConsoleWrite("Error calling _CPUsUsageTracker_Create():" & @error & ", @extended = " & @extended & @CRLF) ; Overall CPU Usage tracker ;~ $aCPUOverallTracker = _CPUOverallUsageTracker_Create() ;~ If @error Then Exit ConsoleWrite("Error calling _CPUOverallUsageTracker_Create():" & @error & ", @extended = " & @extended & @CRLF) $iTotalCPUs = $aCPUsUsageTracker[0][0] ConsoleWrite("Total # CPU's: " & $iTotalCPUs & @CRLF) Sleep(250) $hSplash=SplashTextOn("CPU Usage Information [" & $iTotalCPUs & " total CPU's]", "", _ 240, 20 + ($iTotalCPUs + 1) * 35, Default, Default, 16, Default, 12) ; Start loop Do $aPercents = _CPUsUsageTracker_GetUsage($aCPUsUsageTracker) $sSplashText="" For $i=0 To $iTotalCPUs - 1 $sSplashText &= "CPU #"& $i+1 & ": " & $aPercents[$i] & " %" & @CRLF Next $sSplashText &= @CRLF &"[Overall CPU Usage] :" & $aPercents[$iTotalCPUs] & " %" & @CRLF ; Alternative, if all we wanted was Overall CPU Usage: ;~ $sSplashText &= @CRLF &"[Overall CPU Usage] :" & _CPUOverallUsageTracker_GetUsage($aCPUOverallTracker) & " %" & @CRLF $sSplashText &= @CRLF & "[Esc] exits" ControlSetText($hSplash, "", "[CLASS:Static; INSTANCE:1]", $sSplashText) Sleep(500) Until $bHotKeyPressed _ Overall CPU Usage (and Idle calculation) example: ; ======================================================================================================== ; <CPU_ProcessorUsageOverall.au3> ; ; Example of reading combined overall CPU usage and deducing Idle CPU usage as well ; Readings are shown in a 'Splash' window ; ; Functions: ; _CPUGetTotalProcessorTimes() ; Gets Overall (combined CPUs) Processor Times ; _CPUOverallUsageTracker_Create() ; Creates a CPU usage tracker for Overall CPU usage ; _CPUOverallUsageTracker_GetUsage(); Updates CPU usage tracker and returns CPU usage [Overall Usage] ; ; External Functions: ; _CPUGetIndividualProcessorTimes() ; Returns an array of CPU usage info for individual processors ; _CPUsUsageTracker_Create() ; Creates a CPU usage tracker for all CPUs ; _CPUsUsageTracker_GetUsage() ; Updates CPU usage tracker and returns a CPU usage array ; ; See also: ; <CPU_ProcessorUsage.au3> ; Individual CPU processor usage example ; Performance Counters UDF ; ; ; Author: Ascend4nt ; ======================================================================================================== ; --- UDF's --- ; ============================================================================================== ; Func _CPUGetTotalProcessorTimes() ; ; Gets the total (combined CPUs) system processor times (as FILETIME) ; Note that Kernel Mode time includes Idle Mode time, so a proper calculation of usage time is ; Kernel + User - Idle ; And percentage (based on two readings): ; (Kernel_b - Kernel_a) + (User_b - User_a) - (Idle_b - Idle_a) * 100 ; / (Kernel_b - Kernal_a) + (User_b - User_a) ; ; O/S Requirements: min. Windows XP SP1+ ; ; Returns: ; Success: Array of info for total (combined CPU's) processor times: ; [0] = Idle Mode Time ; [1] = Kernel Mode Time -> NOTE This INCLUDES Idle Time ; [2] = User Mode Time ; ; Failure: "" with @error set: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: API call returned False - call GetLastError for more info ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUGetTotalProcessorTimes() Local $aRet, $aTimes $aRet = DllCall("kernel32.dll", "bool", "GetSystemTimes", "uint64*", 0, "uint64*", 0, "uint64*", 0) If @error Then Return SetError(2, @error, "") If Not $aRet[0] Then Return SetError(3, 0, "") Dim $aTimes[3] = [ $aRet[1], $aRet[2], $aRet[3] ] Return $aTimes EndFunc ; ============================================================================================== ; Func _CPUOverallUsageTracker_Create() ; ; Creates a CPU usage tracker array for Overall combined processors usage. ; This array should be passed to _CPUOverallUsageTracker_GetUsage() to get ; current usage information. ; ; Returns: ; Success: An array used to track Overall CPU usage ; Array 'internal' format: ; $arr[0] = Total Overall CPU Time (Kernel + User Mode) ; $arr[1] = Total Active Overall CPU Time (Kernel + User - Idle) ; ; Failure: "" with @error set [reflects _CPUGetTotalProcessorTimes codes]: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: API call returned False - call GetLastError for more info ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUOverallUsageTracker_Create() Local $aCPUTimes, $aCPUsUsage[2] $aCPUTimes = _CPUGetTotalProcessorTimes() If @error Then Return SetError(@error, @extended, "") ; Total $aCPUsUsage[0] = $aCPUTimes[1] + $aCPUTimes[2] ; TotalActive (Kernel Time includes Idle time, so we need to subtract that) $aCPUsUsage[1] = $aCPUTimes[1] + $aCPUTimes[2] - $aCPUTimes[0] Return $aCPUsUsage EndFunc ; ============================================================================================== ; Func _CPUOverallUsageTracker_GetUsage(ByRef $aCPUsUsage) ; ; Updates a CPUsUsage array and returns CPU Usage information [Overall processor usage] ; ; Returns: ; Success: CPU Usage (Percentage) ; Failure: 0 with @error set to 1 for invalid parameters, or: ; @error = 2: DLLCall error, @extended = error returned from DLLCall ; @error = 3: API call returned False - call GetLastError for more info ; ; Author: Ascend4nt ; ============================================================================================== Func _CPUOverallUsageTracker_GetUsage(ByRef $aCPUsUsage) If Not IsArray($aCPUsUsage) Or UBound($aCPUsUsage) < 2 Then Return SetError(1, 0, "") Local $aCPUsCurInfo, $fUsage, $nTotalActive, $nTotal $aCPUsCurInfo = _CPUOverallUsageTracker_Create() If @error Then Return SetError(@error, @extended, 0) $nTotal = $aCPUsCurInfo[0] - $aCPUsUsage[0] $nTotalActive = $aCPUsCurInfo[1] - $aCPUsUsage[1] ; Replace current usage tracker info $aCPUsUsage = $aCPUsCurInfo Return Round($nTotalActive * 100 / $nTotal, 1) EndFunc ; -------------------- HOTKEY FUNCTION & VARIABLE -------------------- Global $bHotKeyPressed=False Func _EscPressed() $bHotKeyPressed=True EndFunc ; -------------------- MAIN PROGRAM CODE -------------------- HotKeySet("{Esc}", "_EscPressed") Local $hSplash, $sSplashText ; Overall CPU Usage Tracker ; (GetSystemTimes) Local $aCPUOverallTracker, $fPercent ; Overall CPU Usage tracker $aCPUOverallTracker = _CPUOverallUsageTracker_Create() If @error Then Exit ConsoleWrite("Error calling _CPUOverallUsageTracker_Create():" & @error & ", @extended = " & @extended & @CRLF) Sleep(250) $hSplash=SplashTextOn("CPU [Overall] Usage Information", "", _ 240, 100, Default, Default, 16, Default, 12) ; Start loop Do $fPercent = _CPUOverallUsageTracker_GetUsage($aCPUOverallTracker) $sSplashText="" $sSplashText &= "[Overall CPU Usage] :" & $fPercent & " %" & @CRLF $sSplashText &= "[Idle] : " & (100 - $fPercent) & " %" & @CRLF $sSplashText &= @CRLF & "[Esc] exits" ControlSetText($hSplash, "", "[CLASS:Static; INSTANCE:1]", $sSplashText) Sleep(500) Until $bHotKeyPressed CPU_ProcessorUsageOverall.au35 points
-
OOo/LibO Calc UDF
rohmanabdur reacted to GMK for a topic
I decided to enhance the functionality of the OOo COM UDF found >here and >here. Thanks to Leagnus and Andy G for providing the initial functions and framework. This UDF includes the following working functions: _OOoCalc_BookNew _OOoCalc_BookOpen _OOoCalc_BookAttach _OOoCalc_BookSave _OOoCalc_BookSaveAs _OOoCalc_BookClose _OOoCalc_WriteCell _OOoCalc_WriteFormula _OOoCalc_WriteFromArray _OOoCalc_HyperlinkInsert _OOoCalc_RangeMoveOrCopy _OOoCalc_RangeSort _OOoCalc_RangeClearContents _OOoCalc_CreateBorders _OOoCalc_NumberFormat _OOoCalc_ReadCell _OOoCalc_ReadSheetToArray _OOoCalc_RowDelete _OOoCalc_ColumnDelete _OOoCalc_RowInsert _OOoCalc_ColumnInsert _OOoCalc_SheetAddNew _OOoCalc_SheetDelete _OOoCalc_SheetNameGet _OOoCalc_SheetNameSet _OOoCalc_SheetList _OOoCalc_SheetActivate _OOoCalc_SheetSetVisibility _OOoCalc_SheetMove _OOoCalc_SheetPrint _OOoCalc_HorizontalAlignSet _OOoCalc_FontSetProperties _OOoCalc_CellSetColors _OOoCalc_RowSetColors _OOoCalc_ColumnSetColors _OOoCalc_RowSetProperties _OOoCalc_ColumnSetProperties _OOoCalc_FindInRange _OOoCalc_ReplaceInRange Please help me test this and let me know of any problems, questions, suggestions or comments you may have. Edit (August 5, 2016): Latest files have been uploaded. Script-breaking changes include renaming the functions to start with _OOoCalc_. Edit (November 14, 2016): New version, including fixed sort function! Edit (November 15, 2016): Lots of minor changes including tightening up the error checking. Edit (November 16, 2016): Added ByRef to object parameters. Edited demo. OOoCalcConstants.au3 OOoCalc.au3 OOoCalc_Demo.au31 point -
You can find a lot of libraries (DLLs) to create OpenGL windows and contexts, to load images and data into textures, to load 3D models, and to call functions that are not in opengl32.dll. Are all these external libraries necessary? The zip files below contains UDFs to create contexts, load images and models, and call functions without any external libraries. They also contains a number of examples. Well, it's not quite true that I do not use any DLLs at all. In some examples I'm using The Embedded Flat Assembler (FASM) UDF by Ward (includes fasm.dll) to optimize loops. This is the ExLauncher, that can be used to run the examples: Press Play to run the first example, and Next to run the following examples. In the Samples menu you can select OpenGL 1.1, 2.1, and 3.3 examples. With Samples | Models you can open the 3D model Viewers, and run 3D model examples. With Samples | Templates you can see a number of templates, as you can use as a start for your own examples. The documentation is divided into five chapters: Chapter 1 is mostly about OpenGL 1.x. Topics like calling functions, creating a rendering context, and loading images into textures are also covered.Chapter 2 deals with OpenGL 2.x and the new concepts that appeared in these versions. Most important is the concept of shaders.Chapter 3 is mostly about OpenGL 3.x. There is also a section on OpenGL/GLSL versions and a section on error handling.Chapter 4 is about implementing a model loader for Wavefront (OBJ) 3D models.Chapter 5 is a summary.In bottom of the post you can download zip files. Use ExLauncher.au3 in top folder to run examples. To view Wavefront (OBJ) 3D models see section 4.0. Chapter 1 is mostly about OpenGL 1.x. Topics like calling functions, creating a rendering context, and loading images into textures are also covered. 1.1 Calling functions Functions defined in OpenGL 1.2 and higher and functions defined in extensions are part of the software that belongs to the video card. To access these functions you normally use a function loading library e.g. GLEW. You can also access the functions manually: 1.2 Rendering contexts (Update 2013-09-21) With OpenGL 3.0 and higher there are more ways to create a rendering context. In the OpenGL wiki the terms simple and proper are used to describe two different types of contexts. Update: New MSAA context. 1.3 Textures and images (Update 2013-09-21) A texture is an OpenGL object that contains an image. Without an image loading library or at least an image loading function it can be tricky to load an image into a texture. These functions loads BMP, GIF, ICO, JPG, PNG, RGB, RGBA, TGA, TGA(RLE), TIF and WMF files. Update: Anisotropic filter (bottom of spoiler). 1.4 OpenGL 1.1 examples (Update 2013-08-03) SamplesOpenGL 1.1 contains the OpenGL 1.1 examples. Here is a list: 1.5 Run examples (Update 2013-08-03) You can run examples in the Samples folder by double clicking, or you can run them from Scite. The easiest is to use ExLauncher.au3 in the top folder: 1.6 Threads example Imagine that when you move the mouse across the screen, it'll create a track on the screen that follows your mouse. Then imagine that there isn't just one track, but many tracks that are slightly offset relative to each other. This is threads: Chapter 2 deals with OpenGL 2.x and the new concepts that appeared in these versions. Most important is the concept of shaders. 2.1 New concepts In the last versions of OpenGL 1.x and especially in version 2.0 and 2.1 a new set of concepts showed up. It was concepts such as shaders, attributes, uniforms and vertex buffer objects (VBOs): 2.2 Shaders Shaders were introduced in OpenGL 2.0. A shader is a program running on the GPU. You write a shader in the OpenGL Shading Language (GLSL). It's a C-like language: 2.3 Math functions When you use shaders in OpenGL 2.0 and higher you don't use old functions like glMultMatrix, glRotate, glTranslate, gluLookAt or gluPerspective. You have to use a new set of functions that works with the functionality of the shaders: 2.4 OpenGL 2.1 examples (Update 2013-06-16) SamplesOpenGL 2.1 contains the OpenGL 2.1 examples. All these examples are based on shaders and the new concepts in OpenGL 2.1. Here is a list: Chapter 3 is mostly about OpenGL 3.x. There is also a section on OpenGL/GLSL versions and a section on error handling. 3.1 OpenGL versions OpenGL versions and corresponding GLSL version: 3.2 Error handling OpenGL error handling is done with glGetError and glGet-functions. Initialize error handling before a group of commands and check errors after the last command. Here error handling is illustrated with LoadGLSLshader in oglIncludesoglLoadShaders.au3: 3.3 OpenGL 3.3 examples (Update 2013-06-16) SamplesOpenGL 3.3 contains the OpenGL 3.3 examples. Most of these examples are added in an update on 2013-06-16. Chapter 4 is about implementing a model loader for Wavefront (OBJ) 3D models 4.0 View 3D models (New 2014-05-04) Added a few pictures that shows how the model Viewers works. 4.1 3D models (New 2013-08-03) When you need a 3D model in your OpenGL project you probably just want to find the model on the internet and load it into your project with some kind of model loading function. 4.2 Wavefront (OBJ) loader (Update 2013-09-21) A Wavefront 3D model (Wavefront .obj file) consists usually of two files: An OBJ-file (Object files) which contains vertices, texture coordinates, normal vectors and face triangles to describe the geometry of the model. And a MTL-file (Material files) with material definitions to describe the look of the model. Material definitions are parameters for the OpenGL glMaterial command to describe the light reflectivities of the surface of the model, and definitions of texture maps to put on the surface of the model. 4.3 Wavefront (OBJ) viewer (Update 2013-09-21) SamplesModelsModel Viewer contains two viewers for Wavefront (OBJ) 3D models. Model Viewer (OBJ) 1.1.au3 is an OpenGL 1.1 version (2.0 or lower) and Model Viewer (OBJ) 2.1.au3 is a 2.1 version (2.1 or higher). Model Viewer (OBJ).au3 calls the proper script depending on your OpenGL version. The latter can be opened through the Tools menu in ExLauncher.au3. 4.4 Example models (Update 2013-09-21) The Models folder at the top level contains the example models. The SamplesModels folder at the top level contains the viewers and the au3-scripts to run the examples. Example models are split into two groups: Samples and models. Models are further divided into three groups: Small, medium and large models: 4.5 Large models (Update 2013-09-21) The optimizations provided in this update and the 2013-08-24 update has largely eliminated the problems of large models. 4.6 Using the models (Update 2013-09-21) SamplesModelsOpenGL 1.1 and SamplesModelsOpenGL 2.1 contains some small examples which shows how to use the models. 4.7 Software (Update 2013-08-24) Blender is a program to edit 3D models. AssimpView is a model viewer. Both of these programs are able to export a model as a Wavefront (OBJ) triangle mesh. 4.8 Next version (Update 2013-09-21) Some issues should be handled in the next version: 4.9 Summary (Update 2013-09-21) This is a summary of the main features and limitations for the Wavefront (OBJ) 3D model loader: Chapter 5 is a summary 5.1 Sources for the UDFs (New 2013-06-16) The zipfile contains a number of OpenGL UDFs in the oglIncludes folder. This is a description of the sources for these UDFs: 5.2 Updates (New 2014-05-04) The example was released 2013-05-19. This is a summary of the updates. Zip files and downloads Included UDFs FASM.au3 and MemoryDll.au3 by Ward to optimize loops. The UDFs are included in the code zip. Contents of the code zip The zipfiles contains a number of files and folders: ExLauncher.au3 - to start the examples, run this fileImages - images used in the examples (not since 2014-05-04)Models - Wavefront (OBJ) 3D example modelsIncludes - utility functions and UDFsoglIncludes - OpenGL related constants and functionsSamples - a collection of examples and templatesTools - a few OpenGL toolszLinks - links to dokuUpdate 2014-05-04 for AutoIt 3.3.10 (code): OpenGL2-3.3.10.7z Downloads at Dropbox The images and 3D models can be downloaded from OpenGL Images and Models at Dropbox. The folder contains three 7z-files: Images.7z, 3.5 MB - the images from the first release 2013-05-19. You need these images, but if you have already installed the images, you do not need to download this package.ModelSamples.7z, 1.66 MB - sample 3D models. If you want to test the Wavefront (OBJ) 3D models and the model loading functions, you need this package.Models.7z, 39.15 MB (250 MB uncompressed) - larger models. The pictures in post 13, 14 and 16 are created from models in this package.If you don't want to test any 3D models there is no need to download and install the last two packages.Click the Download button in upper right corner to download all three packages in one big zip. Testet on XP 32 bit with a NVIDIA video card supporting OpenGL 3.3 and Win 7 64 bit with an Intel card supporting OpenGL 3.1. Use ExLauncher.au3 in top folder to run examples. To view Wavefront (OBJ) 3D models see section 4.0. AutoIt 3.3.8 You can get the 2013-09-21 version for 3.3.8 here. You need the images and possibly the 3D models. x64 issues (no x64 issues in 3.3.10)1 point
-
Sure, here is an example of saving a page after searching for something in google #include <IE.au3> Local $oIE = _IECreate("http://www.google.com", 0, 0) Local $oForm = _IEFormGetCollection($oIE, 0) Local $oQuery = _IEFormElementGetObjByName($oForm, "q") _IEFormElementSetValue($oQuery, "AutoIt IE.au3") _IEFormSubmit($oForm) While _IEPropertyGet($oIE, "busy") Sleep(100) WEnd FileWrite(@MyDocumentsDir & '\Results.html', _IEDocReadHTML($oIE)) _IEQuit($oIE) ShellExecute(@MyDocumentsDir & '\Results.html') Hope this helps1 point
-
#include <array.au3> $aTest = GetNics() _ArrayDisplay($aTest) Func GetNics() Local $NETWORK_REG_KEY = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" Local $tagIP_ADDRESS_STRING = "char IPAddress[16];" Local $tagIP_MASK_STRING = "char IPMask[16];" Local $tagIP_ADDR_STRING = "ptr Next;" & $tagIP_ADDRESS_STRING & $tagIP_MASK_STRING & "DWORD Context;" Local $tagIP_ADAPTER_INFO = "ptr Next; DWORD ComboIndex; char AdapterName[260];char Description[132]; UINT AddressLength; BYTE Address[8]; dword Index; UINT Type;" & _ " UINT DhcpEnabled; ptr CurrentIpAddress; ptr IpAddressListNext; char IpAddressListADDRESS[16]; char IpAddressListMASK[16]; DWORD IpAddressListContext; " & _ "ptr GatewayListNext; char GatewayListADDRESS[16]; char GatewayListMASK[16]; DWORD GatewayListContext; " & _ "ptr DhcpServerNext; char DhcpServerADDRESS[16]; char DhcpServerMASK[16]; DWORD DhcpServerContext; " & _ "int HaveWins; " & _ "ptr PrimaryWinsServerNext; char PrimaryWinsServerADDRESS[16]; char PrimaryWinsServerMASK[16]; DWORD PrimaryWinsServerContext; " & _ "ptr SecondaryWinsServerNext; char SecondaryWinsServerADDRESS[16]; char SecondaryWinsServerMASK[16]; DWORD SecondaryWinsServerContext; " & _ "DWORD LeaseObtained; DWORD LeaseExpires;" Local $dll = DllOpen("Iphlpapi.dll") Local $ret = DllCall($dll, "dword", "GetAdaptersInfo", "ptr", 0, "dword*", 0) Local $adapterBuffer = DllStructCreate("byte[" & $ret[2] & "]") Local $adapterBuffer_pointer = DllStructGetPtr($adapterBuffer) Local $return = DllCall($dll, "dword", "GetAdaptersInfo", "ptr", $adapterBuffer_pointer, "dword*", $ret[2]) Local $adapter = DllStructCreate($tagIP_ADAPTER_INFO, $adapterBuffer_pointer) If Not @error Then Dim $aAdapters[100][4] $i = 0 Do $aAdapters[$i][0] = DllStructGetData($adapter, "Description") $aAdapters[$i][1] = RegRead($NETWORK_REG_KEY & DllStructGetData($adapter, "AdapterName") & "\Connection", "Name") $aAdapters[$i][2] = DllStructGetData(DllStructCreate($tagIP_ADDR_STRING, DllStructGetPtr($adapter, "IpAddressListNext")), "IPAddress") $aAdapters[$i][3] = DllStructGetData(DllStructCreate($tagIP_ADDR_STRING, DllStructGetPtr($adapter, "IpAddressListNext")), "IPMask") $i += 1 $ptr = DllStructGetData($adapter, "Next") $adapter = DllStructCreate($tagIP_ADAPTER_INFO, $ptr) Until @error ReDim $aAdapters[$i][4] EndIf Return $aAdapters EndFunc ;==>GetNics1 point
-
dolphins, Did a friend say to you, "that code/idea would be better suited in C#" ?1 point
-
Any chance you will be adding the image search functionality? Beeing able to search the same screenshot for several images would speed up my project alot. Wishlist: Load snapshot from bmp/jpg Find (smaler) snapshot inside another snapshot (option to return "found(true/false)" or array of results with coords)1 point
-
Did you notice in my code I correctly set the controls to show and hide, where in your code they don't do anything, and here's why. First, you're using -1 for the control id for GUICtrlSetState, which is ONLY to be used for the last control id or handle created, next you're reassigning the variable that holds the control ID for the controls to the return value from GUICtrlSetState, this causes your script to never display your controls because you never tell it to show any controls except the last one and you're destroying any connection you might have had to the controls because of the variable reassigning.1 point
-
Mouse Click Counter
TheSeeker reacted to lorenkinzel for a topic
I'm going to go out on a limb here, as I am by no strech of the imagination, the guy to help with or fix your code. But here's what I was playing with: Edit: cleaned-up the 'stumble' in the subtract (of this version; original version didn't have that problem). Edit2: note to self; finish script, THEN post. Edit3: I have a clearer understanding of your methods. It was fun to try though.... ; From dipan , 16 Jun 2013. #include <GUIConstantSex.au3> #include <StaticConstants.au3> #include "Misc.au3" Opt("GUIOnEventMode", 1) Global $clicks $Form1 = GUICreate("#", 109, 95, 350, 143);Once I changed the size there was no room left for the title.Sorry GUISetOnEvent($GUI_EVENT_CLOSE, "xIt") $label1 = GUICtrlCreateLabel("0", 2, 2, 105, 35, $SS_CENTER) GUICtrlSetFont(-1, 20, 400, 0, "Times New Roman") $buttonMinus = GUICtrlCreateButton("-", 2, 39, 39, 27) GUICtrlSetOnEvent($buttonMinus, "subtractOne") GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $buttonPlus = GUICtrlCreateButton("+", 68, 39, 39, 27) ;GUICtrlSetOnEvent($buttonPlus, "addOne") GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $buttonClear = GUICtrlCreateButton("Clear", 2, 68, 105, 25) GUICtrlSetOnEvent($buttonClear, "resetToZero") GUISetState(@SW_SHOW) WinSetOnTop("#", "", 1) While 1 Sleep(10) If _IsPressed(01) Then addOne() EndIf While _IsPressed(01) Sleep(10) WEnd WEnd Func xIt() Exit EndFunc ;==>xIt Func addOne() $clicks += 1 GUICtrlSetData($label1, $clicks) EndFunc ;==>addOne Func subtractOne() $clicks -= 2 GUICtrlSetData($label1, $clicks) $readLabel1 = GUICtrlRead($label1) If $readLabel1 < 0 Then EndIf EndFunc ;==>subtractOne Func resetToZero() $clicks = 0 GUICtrlSetData($label1, $clicks) EndFunc ;==>resetToZero1 point -
Ouch; definatly on the proper control. Not sure what's up...odd that the bFocus is 0...maybe the window state is not valid...add this after your function (if the window is enabled, then i'm out of ideas) ConsoleWrite("Starting" & @crlf) $hwnd = _WinWaitActivate("AutoIt Help", "") If IsHWnd($hwnd) Then ConsoleWrite("Able to find window" & @CRLF) Else ConsoleWrite("Unable to find window" & @CRLF) Exit 1 EndIf $iWinState = WinGetState($hwnd) ConsoleWrite("$iWinState=[" & $iWinState & "]" & @CRLF)1 point
-
try again with this, and we will verify you are grabbing the proper control: #include <array.au3> #include <WinAPI.au3> #include <GuiComboBox.au3> #RequireAdmin Func Var_GetAllWindowsControls2($hCallersWindow) $sClassList = WinGetClassList($hCallersWindow) $aClassList = StringSplit($sClassList, @CRLF, 2) _ArraySort($aClassList) _ArrayDelete($aClassList, 0) $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) If IsArray($aPos) Then ConsoleWrite(" Func=[Var_GetAllWindowsControls]: ControlCounter=[" & $iTotalCounter & "] ControlID=[" & $sControlID & "] Handle=[" & $hControl & "] ClassNN=[" & $iCurrentClass & $iCurrentCount & "] XPos=[" & $aPos[0] & "] YPos=[" & $aPos[1] & "] Width=[" & $aPos[2] & "] Height=[" & $aPos[3] & "] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>Var_GetAllWindowsControls2 Func _WinWaitActivate($title, $text, $timeout = 5) $hReturn = WinWait($title, $text, $timeout) If Not IsHWnd($hReturn) Then Return False If Not WinActive($hReturn) Then WinActivate($hReturn) If WinWaitActive($hReturn, "", $timeout) Then Return $hReturn Else Return False EndIf EndFunc ;==>_WinWaitActivate ConsoleWrite("Starting" & @crlf) $hwnd = _WinWaitActivate("AutoIt Help", "") If IsHWnd($hwnd) Then ConsoleWrite("Able to find window" & @CRLF) Else ConsoleWrite("Unable to find window" & @CRLF) Exit 1 EndIf Var_GetAllWindowsControls2($hwnd) $hControl = ControlGetHandle($hwnd, "", 1) If IsHWnd($hControl) Then $bFocus = ControlFocus($hwnd,"",$hControl) $bVisible = ControlCommand($hwnd,"",$hControl,"IsVisible", "") $bEnabled = ControlCommand($hwnd,"",$hControl,"IsEnabled", "") $aPos = ControlGetPos($hwnd,"",$hControl) ConsoleWrite("Able to find button; $bFocus=[" & $bFocus & "], $bVisible=[" & $bVisible & "], $bEnabled=[" & $bEnabled & "], x=[" & $aPos[0] & "], y=[" & $aPos[1] & "], width=[" & $aPos[2] & "], height=[" & $aPos[3] & "]." & @CRLF) Else ConsoleWrite("Unable to focus on button" & @CRLF) Exit 2 EndIf If ControlClick($hwnd,"",$hControl) Then ConsoleWrite("Able to click button" & @CRLF) Else ConsoleWrite("Unable to click button" & @CRLF) Exit 3 EndIf1 point
-
Try this out, paste back the consolewrites, that will help us find the failure point #include <array.au3> #include <GuiComboBox.au3> #RequireAdmin Func _WinWaitActivate($title, $text, $timeout = 5) $hReturn = WinWait($title, $text, $timeout) If Not IsHWnd($hReturn) Then Return False If Not WinActive($hReturn) Then WinActivate($hReturn) If WinWaitActive($hReturn, "", $timeout) Then Return $hReturn Else Return False EndIf EndFunc ;==>_WinWaitActivate ConsoleWrite("Starting" & @crlf) $hwnd = _WinWaitActivate("Dexterity Runtime", "") If IsHWnd($hwnd) Then ConsoleWrite("Able to find window" & @CRLF) Else ConsoleWrite("Unable to find window" & @CRLF) Exit 1 EndIf $hControl = ControlGetHandle($hwnd, "", 1) If IsHWnd($hControl) Then $bFocus = ControlFocus($hwnd,"",$hControl) $bVisible = ControlCommand($hwnd,"",$hControl,"IsVisible", "") $bEnabled = ControlCommand($hwnd,"",$hControl,"IsEnabled", "") ConsoleWrite("Able to find button; $bFocus=[" & $bFocus & "], $bVisible=[" & $bVisible & "], $bEnabled=[" & $bEnabled & "]." & @CRLF) Else ConsoleWrite("Unable to focus on button" & @CRLF) Exit 2 EndIf If ControlClick($hwnd,"",$hControl) Then ConsoleWrite("Able to click button" & @CRLF) Else ConsoleWrite("Unable to click button" & @CRLF) Exit 3 EndIf1 point
-
mwhidden, No, I said that your assertion "that the values are converted to numbers" was not true. And it is not true in all cases, as I explained. If you want to suggest a change to the documentation - then provide some suitable wording to replace/add to what is already there and post in this thread. Whether guinness accepts it is, of course, another matter. M23 P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unneccessarily.1 point
-
Right to Left texts in menus
mohammadezazi reacted to Mat for a topic
Like I said previously, you can't use the standard AutoIt menu, so there are a couple of extra steps. Is this the output you were expecting? #include <Constants.au3> #include <MenuConstants.au3> #include <GUIMenu.au3> #include <Process.au3> #NoTrayIcon Opt("TrayMenuMode", 1) Local Enum $item1 = 1000, $item2, $item3, $item4, $item5, $item6, $itemAbout, $itemExit Local $hWindow = WinGetHandle(AutoItWinGetTitle()) ;----------------Create Menu----------------------------------- Local $webservicesitem = _GUICtrlMenu_CreatePopup("سرويسهاي وب") _GUICtrlMenu_AddMenuItem($webservicesitem, "سرويس وب اول", $item1) _GUICtrlMenu_AddMenuItem($webservicesitem, "اتوماسيون", $item2) _GUICtrlMenu_AddMenuItem($webservicesitem, "منابع انساني", $item3) _GUICtrlMenu_AddMenuItem($webservicesitem, "I want to justify these Arabic items to the right side of submenu", $item4) _GUICtrlMenu_AddMenuItem($webservicesitem, "کدينگ", $item5) _GUICtrlMenu_AddMenuItem($webservicesitem, "How I can justify these items Arabic texts to right side of menu?", $item6) _GUICtrlMenu_AddMenuItem($webservicesitem, "About", $itemAbout) _GUICtrlMenu_AddMenuItem($webservicesitem, "خروج", $itemExit) TraySetState() TraySetClick(0) ;-------------------------------------------------------- While 1 Local $msg = TrayGetMsg() If $msg = $TRAY_EVENT_SECONDARYDOWN Then $item = _GUICtrlMenu_TrackPopupMenu2($webservicesitem, $hWindow, -1, -1, 1, 1, 2, 0, True) Select Case $item = 0 ContinueLoop Case $item = $item1 Local $rc = _RunDos("start Http://www.google.com")1 point -
Never seen that, i would try to make a script that detects the mouse click, and then have a timer, after that key has been pressed for more than X msecs, force button up. Not sure how it can be done, but i believe it's possible, as for this udf, i don't see the option you need, available. Sugestion: _ispressed, timerinit, send1 point
-
If all you are looking for is IP in relation to adapter name, try this out. #include <array.au3> $aTest = GetNics() _ArrayDisplay($aTest) Func GetNics() Local $NETWORK_REG_KEY = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" Local $tagIP_ADDRESS_STRING = "char IPAddress[16];" Local $tagIP_MASK_STRING = "char IPMask[16];" Local $tagIP_ADDR_STRING = "ptr Next;" & $tagIP_ADDRESS_STRING & $tagIP_MASK_STRING & "DWORD Context;" Local $tagIP_ADAPTER_INFO = "ptr Next; DWORD ComboIndex; char AdapterName[260];char Description[132]; UINT AddressLength; BYTE Address[8]; dword Index; UINT Type;" & _ " UINT DhcpEnabled; ptr CurrentIpAddress; ptr IpAddressListNext; char IpAddressListADDRESS[16]; char IpAddressListMASK[16]; DWORD IpAddressListContext; " & _ "ptr GatewayListNext; char GatewayListADDRESS[16]; char GatewayListMASK[16]; DWORD GatewayListContext; " & _ "ptr DhcpServerNext; char DhcpServerADDRESS[16]; char DhcpServerMASK[16]; DWORD DhcpServerContext; " & _ "int HaveWins; " & _ "ptr PrimaryWinsServerNext; char PrimaryWinsServerADDRESS[16]; char PrimaryWinsServerMASK[16]; DWORD PrimaryWinsServerContext; " & _ "ptr SecondaryWinsServerNext; char SecondaryWinsServerADDRESS[16]; char SecondaryWinsServerMASK[16]; DWORD SecondaryWinsServerContext; " & _ "DWORD LeaseObtained; DWORD LeaseExpires;" Local $dll = DllOpen("Iphlpapi.dll") Local $ret = DllCall($dll, "dword", "GetAdaptersInfo", "ptr", 0, "dword*", 0) Local $adapterBuffer = DllStructCreate("byte[" & $ret[2] & "]") Local $adapterBuffer_pointer = DllStructGetPtr($adapterBuffer) Local $return = DllCall($dll, "dword", "GetAdaptersInfo", "ptr", $adapterBuffer_pointer, "dword*", $ret[2]) Local $adapter = DllStructCreate($tagIP_ADAPTER_INFO, $adapterBuffer_pointer) If Not @error Then Dim $aAdapters[100][3] $i = 0 Do $aAdapters[$i][0] = DllStructGetData($adapter, "Description") $aAdapters[$i][1] = RegRead($NETWORK_REG_KEY & DllStructGetData($adapter, "AdapterName") & "\Connection", "Name") $aAdapters[$i][2] = DllStructGetData(DllStructCreate($tagIP_ADDR_STRING, DllStructGetPtr($adapter, "IpAddressListNext")), "IPAddress") $i += 1 $ptr = DllStructGetData($adapter, "Next") $adapter = DllStructCreate($tagIP_ADAPTER_INFO, $ptr) Until @error ReDim $aAdapters[$i][3] EndIf Return $aAdapters EndFunc ;==>GetNics NOTE: >All thanks to the work done by ProgAndy in this thread.1 point