Markos Posted March 30, 2009 Posted March 30, 2009 (edited) Hi, I am trying to make script that detects the actual speed of my Wlan - it sometimes stucks on 5.5 Mbits and i have to reconnect to wlan to get the full speed again. I've been searching quite long for func that can retrieve the information - without success. Now I found some function on MSDN that should be able to return the speed - MultinetGetConnectionPerformance. The point is that the function requires input from another function and that from another function, ... and so I got lost. I really dont know how to continue so I would be glad if somebody gives me a helping hand. ;http://msdn.microsoft.com/en-us/library/aa385353(VS.85).aspx ;typedef struct _NETRESOURCE {DWORD dwScope;DWORD dwType;DWORD dwDisplayType;DWORD dwUsage;LPTSTR lpLocalName;LPTSTR lpRemoteName;LPTSTR lpComment; LPTSTR lpProvider; Local $NETRESOURCESTRUCT = DllStructCreate('dword;dword;dword;dword;str;str;str;str') ;typedef struct _NETCONNECTINFOSTRUCT { DWORD cbStructure; DWORD dwFlags; DWORD dwSpeed; DWORD dwDelay; DWORD dwOptDataSize; Local $NETCONNECTINFOSTRUCT = DllStructCreate('dword cbStructure;dword dwFlags;dword dwSpeed;dword dwDelay;dword deOptDataSize') #cs http://msdn.microsoft.com/en-us/library/aa385449(VS.85).aspx __in HANDLE hEnum, __inout LPDWORD lpcCount, __out LPVOID lpBuffer, __inout LPDWORD lpBufferSize ); #ce DllCall('Mpr.dll', 'dword', 'WNetEnumResource', 'ptr', $hEnum, 'dword*', $lpcCount, 'ptr', $lpBuffer, 'dword*', $lpBufferSize) ; http://msdn.microsoft.com/en-us/library/aa385342(VS.85).aspx DllCall('Mpr.dll', 'dword', 'MultinetGetConnectionPerformance', 'ptr', DllStructGetPtr($NETRESOURCESTRUCT), 'ptr', DllStructGetPtr($NETCONNECTINFOSTRUCT)) MsgBox(0, '', DllStructGetData($NETCONNECTINFOSTRUCT, 'dwSpeed')) Edited April 6, 2009 by Markos
Ascend4nt Posted March 31, 2009 Posted March 31, 2009 (edited) Try out my Performance Counters UDF, see if there's something there you can use - its in my signature. I recommend trying the 'TestPDH_PerformanceCounters' function and going to 'Manual Entry' (after the initial selection box - which you can't bypass currently, so select anything and go to the next screen) and enter this: \Network Interface(*)\* If you have multiple cards, it will list them all, but you can adjust it for the card you want to look at (the wildcard in parentheses should be modified). Hope maybe that helps *shrug* Edited March 31, 2009 by ascendant My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
WideBoyDixon Posted March 31, 2009 Posted March 31, 2009 Why not time how long it takes to download a small-ish file by FTP or HTTP? MultinetGetConnectionPerformance is only making a guess based on recent throughput so this method would probably be just as reliable ... WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
BrettF Posted March 31, 2009 Posted March 31, 2009 WideBoy, unless it was local, wouldn't it give an indication of WAN speed? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Markos Posted April 6, 2009 Author Posted April 6, 2009 So I have finally took deeper look into ascendant's functions. Thank you - your funcs are gr8 piece of work, that is exactly what I was looking for. If anybody is interested in what I was trying to accomplish - here is the code: #include "_PDH_PerformanceCounters.au3" #include "Native_Wifi_Func_V2_1.au3" Local $sObject = '\Rozhraní sítě(Bezdrátová dvoupásmová minikarta Dell 1490 WLAN)\Aktuální šířka pásma' Global $sSSID = 'Mi-Fi' Global $iRecheckTime = 60000 Global $iReconnectIfLowerThan = 5500000 Global $hPDH_QueryHandle = _PDH_GetNewQueryHandle() Global $hPDH_CounterHandle = _PDH_AddCounter($hPDH_QueryHandle, $sObject) Global $hClientHandle = _Wlan_OpenHandle() Global $pGUID = _Wlan_EnumInterfaces($hClientHandle) Global $aInterfaceRes While 1 $aInterfaceRes = _Wlan_QueryInterface($hClientHandle, $pGUID[0][0], 3) ;~ If Not IsArray($aInterfaceRes) ThenConsoleWrite('Disconnected' & @CRLF) If IsArray($aInterfaceRes) And $aInterfaceRes[1] = $sSSID And _PDH_UpdateCounter($hPDH_QueryHandle,$hPDH_CounterHandle) <= $iReconnectIfLowerThan Then _Wlan_Disconnect($hClientHandle, $pGUID[0][0]) _Wlan_Connect($hClientHandle, $pGUID[0][0], $sSSID) EndIf Sleep($iRecheckTime) WEnd Func OnAutoItExit() _Wlan_CloseHandle($hClientHandle) _PDH_FreeQueryHandle($hPDH_QueryHandle) _PDH_UnInit($hPDH_QueryHandle) EndFunc
Ascend4nt Posted April 6, 2009 Posted April 6, 2009 Glad I could help, not quite sure what Counter you are using (don't understand that language) - but you forgot an important part of the code - _PDH_Init(). That should be called prior to getting new Query Handles. It will prevent the Query Handles & Counter Handles from returning constant errors. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now