Jump to content

Recommended Posts

Posted

Hi, I've already trawled the forum looking for an answer to this but without much luck :

Quite simply I want to check to see if the laptop, the script is running on, is attached to the AC adapter or running on battery.

Then I want the script to carry on if it is, and throw up a message box prompting the user to attach the power supply if it isn't.

I found some information on creating an array from WMI and then tried converting it to a string and it all gets a bit messy. Is there a simple way of finding out if it's on AC or DC. I don't need to know charging time remaining etc, Just on battery or on AC. Is it really that difficult?

Thanks in advance, my head is about to go bang.

Posted

Here's a UDF that should make life easier for you:

Thanks abberation, I had already found this but I'm struggling to get the information this provides in a format that I can use. How can I query the array to get a simple true or false or 1 or 0.

Do I use _ArraySearch _ArrayToClip _ArrayToString?

I'm at the limit of my AutoIt knowledge now.

Posted

After the _ArrayDisplay code, add these lines:

If $batt[0] = 0 Then
    MsgBox(0, "", "The laptop is not plugged in")
ElseIf $batt[0] = 1 Then
    MsgBox(0, "", "The laptop IS plugged in")
Else
    MsgBox(0, "", "I don't know if the laptop is plugged in")
EndIf

The variable $batt[0] holds the answer. If it is equal to 0 then the laptop is not plugged in. If equal to 1 then it is.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...