dickep Posted June 21, 2008 Share Posted June 21, 2008 (edited) OK, I will admit I know nothing about how to call a dll for the information. I have looked on here and found some of what I want/need and now have another but no example.I want to get more data from a laptop battery. I have used COMPINFO but some of the info is not either there or I cannot access it with this tool.I have also done:Global $SYSTEM_POWER_STATUS = DLLStructCreate("byte;byte;byte;byte;int;int") $test = DLLCall("kernel32.dll","int","GetSystemPowerStatus", _ "ptr",DllStructGetPtr($SYSTEM_POWER_STATUS))to get the BatteryFlag information.I still need some information.According to Microsoft KB, there is a lot more ways to possibly get the battery information.Here is the link to Battery_Status structure Battery_Status MSDN Topic and the SYSTEM_BATTERY_STATE sturcture SYSTEM_BATTERY_STATE MSDN topicSo, can someone give me how to call and use the information gathered?Thanks E Edited June 21, 2008 by dickep Link to comment Share on other sites More sharing options...
rasim Posted June 21, 2008 Share Posted June 21, 2008 dickepTry this. Not tested, because i don`t have a laptop:expandcollapse popupDim $serial, $objWMIService, $colItems, $strComputer = ".", $ResultString $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_PortableBattery ") For $objItem In $colItems $ResultString &= "Availability: " & $objItem.Availability & @LF $ResultString &= "Battery Recharge Time: " & $objItem.BatteryRechargeTime & @LF $ResultString &= "Battery Status: " & $objItem.BatteryStatus & @LF $ResultString &= "Capacity Multiplier: " & $objItem.CapacityMultiplier & @LF $ResultString &= "Chemistry: " & $objItem.Chemistry & @LF $ResultString &= "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @LF $ResultString &= "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @LF $ResultString &= "CreationClassName: " & $objItem.CreationClassName & @LF $ResultString &= "Description: " & $objItem.Description & @LF $ResultString &= "DesignCapacity: " & $objItem.DesignCapacity & @LF $ResultString &= "DesignVoltage: " & $objItem.DesignVoltage & @LF $ResultString &= "DeviceID: " & $objItem.DeviceID & @LF $ResultString &= "ErrorCleared: " & $objItem.ErrorCleared & @LF $ResultString &= "ErrorDescription: " & $objItem.ErrorDescription & @LF $ResultString &= "EstimatedChargeRemaining: " & $objItem.EstimatedChargeRemaining & @LF $ResultString &= "EstimatedRunTime: " & $objItem.EstimatedRunTime & @LF $ResultString &= "ExpectedBatteryLife: " & $objItem.ExpectedBatteryLife & @LF $ResultString &= "ExpectedLife: " & $objItem.ExpectedLife & @LF $ResultString &= "FullChargeCapacity: " & $objItem.FullChargeCapacity & @LF $ResultString &= "InstallDate: " & $objItem.InstallDate & @LF $ResultString &= "LastErrorCode: " & $objItem.LastErrorCode & @LF $ResultString &= "Location: " & $objItem.Location & @LF $ResultString &= "ManufactureDate: " & $objItem.ManufactureDate & @LF $ResultString &= "Manufacturer: " & $objItem.Manufacturer & @LF $ResultString &= "MaxBatteryError: " & $objItem.MaxBatteryError & @LF $ResultString &= "MaxRechargeTime: " & $objItem.MaxRechargeTime & @LF $ResultString &= "Name: " & $objItem.Name & @LF $ResultString &= "PNPDeviceID: " & $objItem.PNPDeviceID & @LF $ResultString &= "PowerManagementSupported: " & $objItem.PowerManagementSupported & @LF $ResultString &= "SmartBatteryVersion: " & $objItem.SmartBatteryVersion & @LF $ResultString &= "Status: " & $objItem.Status & @LF $ResultString &= "StatusInfo: " & $objItem.StatusInfo & @LF $ResultString &= "SystemCreationClassName: " & $objItem.SystemCreationClassName & @LF $ResultString &= "SystemName: " & $objItem.SystemName & @LF $ResultString &= "TimeOnBattery: " & $objItem.TimeOnBattery & @LF $ResultString &= "TimeToFullCharge: " & $objItem.TimeToFullCharge Next MsgBox(0, "", $ResultString) Link to comment Share on other sites More sharing options...
dickep Posted June 21, 2008 Author Share Posted June 21, 2008 Did not get all the data. This was the same as COMPINFO.AU3 and I need to get the information from the DLL stuff, I think. Surprised no one could direct me on how to setup and use the DLL's that I have referenced. Thanks E Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 21, 2008 Moderators Share Posted June 21, 2008 Did not get all the data. This was the same as COMPINFO.AU3 and I need to get the information from the DLL stuff, I think. Surprised no one could direct me on how to setup and use the DLL's that I have referenced. Thanks ENot everyone has a laptop to test them on... and those of us that do (don't necessarily have AutoIt installed on their laptop (that's me lol)).Global $tag_BATTERY_STATUS = DllStructCreate("ulong[3];long") Global $tag_SYSTEM_BATTERY_STATE = DllStructCreate("int[5];dword[6]") Global $tag_SYSTEM_POWER_STATUS = DllStructCreate("byte[4];dword[2]") Global $aBS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_BATTERY_STATUS)) Global $aSBS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_SYSTEM_BATTERY_STATE)) Global $aSPS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_SYSTEM_POWER_STATUS)) ;Battery Status ConsoleWrite("Battery Status" & @CRLF) For $i = 1 To 4 ConsoleWrite($i & "). " & DllStructGetData($tag_BATTERY_STATUS, $i) & @CRLF) Next ;System Battery State ConsoleWrite(@CRLF & "System Battery State" & @CRLF) For $i = 1 To 11 ConsoleWrite($i & "). " & DllStructGetData($tag_SYSTEM_BATTERY_STATE, $i) & @CRLF) Next ;System Power Status ConsoleWrite(@CRLF & "System Power Status: " & @CRLF) For $i = 1 To 6 ConsoleWrite($i & "). " & DllStructGetData($tag_SYSTEM_POWER_STATUS, $i) & @CRLF) NextSo without really knowing if the above actually outputs the correct info (Unable to test on a laptop), it's how I read them. And should be enough for you to do the others. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
ProgAndy Posted June 21, 2008 Share Posted June 21, 2008 (edited) You made the Dllstructs the wrong way. This way it works: Global $tag_BATTERY_STATUS = DllStructCreate("ulong;ulong;ulong;long") Global $tag_SYSTEM_BATTERY_STATE = DllStructCreate("int;int;int;int;int[4];dword;dword;dword;dword;dword;dword") Global $tag_SYSTEM_POWER_STATUS = DllStructCreate("byte;byte;byte;byte;dword;dword") Global $aBS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_BATTERY_STATUS)) Global $aSBS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_SYSTEM_BATTERY_STATE)) Global $aSPS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_SYSTEM_POWER_STATUS)) ;Battery Status ConsoleWrite("Battery Status" & @CRLF) For $i = 1 To 4 ConsoleWrite($i & "). " & DllStructGetData($tag_BATTERY_STATUS, $i) & @CRLF) Next ;System Battery State ConsoleWrite(@CRLF & "System Battery State" & @CRLF) For $i = 1 To 11 ConsoleWrite($i & "). " & DllStructGetData($tag_SYSTEM_BATTERY_STATE, $i) & @CRLF) Next ;System Power Status ConsoleWrite(@CRLF & "System Power Status: " & @CRLF) For $i = 1 To 6 ConsoleWrite($i & "). " & DllStructGetData($tag_SYSTEM_POWER_STATUS, $i) & @CRLF) Next Edited June 21, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 21, 2008 Moderators Share Posted June 21, 2008 You made the Dllstructs the wrong way. This way it works: Global $tag_BATTERY_STATUS = DllStructCreate("ulong;ulong;ulong;long") Global $tag_SYSTEM_BATTERY_STATE = DllStructCreate("int;int;int;int;int[4];dword;dword;dword;dword;dword;dword") Global $tag_SYSTEM_POWER_STATUS = DllStructCreate("byte;byte;byte;byte;dword;dword") Global $aBS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_BATTERY_STATUS)) Global $aSBS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_SYSTEM_BATTERY_STATE)) Global $aSPS = DllCall("Kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($tag_SYSTEM_POWER_STATUS)) ;Battery Status ConsoleWrite("Battery Status" & @CRLF) For $i = 1 To 4 ConsoleWrite($i & "). " & DllStructGetData($tag_BATTERY_STATUS, $i) & @CRLF) Next ;System Battery State ConsoleWrite(@CRLF & "System Battery State" & @CRLF) For $i = 1 To 11 ConsoleWrite($i & "). " & DllStructGetData($tag_SYSTEM_BATTERY_STATE, $i) & @CRLF) Next ;System Power Status ConsoleWrite(@CRLF & "System Power Status: " & @CRLF) For $i = 1 To 6 ConsoleWrite($i & "). " & DllStructGetData($tag_SYSTEM_POWER_STATUS, $i) & @CRLF) NextSo I did. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
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