Sign in to follow this  
Followers 0
Holmesware

Detect and take action on standby

5 posts in this topic

Please help

I've been trying to figure out how I can close my mail program (Eudora) before TrueCrypt dismounts an encrypted file container when the system goes into standby/hibernation. I have a script that will work for shutdown:

DllCall("kernel32.dll", "int", "SetProcessShutdownParameters", "long", 0x3FF, "long", 0);makes this program get a "Shutdown" message before other programs

RunWait(IniRead("EES.ini","Program","Location","Not Found")); Read the location of Eudora.exe from the INI file

Func OnAutoItExit(); Distinguished function name runs when this program is signaled to shut down
    If @ExitMethod = 4 Then CloseEudora(); Shutting down, so shut down Eudora
EndFunc

Func CloseEudora()
   ; This will run before most programs get shut down, e.g. TrueCrypt
    $PID = ProcessExists("Eudora.exe"); Will return the PID or 0 if the process isn't found.
    If $PID Then
        ProcessClose($PID);
        ProcessWaitClose($PID);
    EndIf
EndFunc

I believe the VB script is this, just not sure how to get it into AutoIt.

Set wmiPowerManagementEvent = GetObject("winmgmts:").ExecNotificationQuery("Select * from Win32_PowerManagementEvent")

If wmiPowerManagementEvent.NextEvent.EventType = 4 Then <do stuff>

here is a link to that may help. http://msdn.microsoft.com/en-us/library/aa394362(VS.85).aspx

I've tried the AutoIt Scriptomatic but there is no entry for Win32_PowerManagementEvent

Thanks so much for your help, I have 3 consultants wanting this script.

Share this post


Link to post
Share on other sites



Dim $strComputer = "localhost", $message_title, $message_content
$oBJ = ObjGet ("winmgmts:\\" & $strComputer & "\root\cimv2")
$event = $oBJ.ExecNotificationQuery("Select * from Win32_PowerManagementEvent")
$ret = $event.NextEvent.EventType
Switch $ret
    Case 4
        $message_title = "Entering Suspend"
        $message_content = "Indicates that the computer is about to enter the suspended state."
    Case 7
        $message_title = "Resume from Suspend"
        $message_content = "Indicates that a ResumeSuspend message has been sent, enabling the computer to return to its regular power state."
    Case 10
        $message_title = "Power Status Change"
        $message_content = "Indicates a change in the power status of the computer, such as a switch from battery power to AC, or from AC to an uninterruptible power supply"
    Case 11
        $message_title = "OEM Event"
        $message_content = "Indicates that an Advanced Power Management (APM) BIOS has sent an OEM event"
    Case 18
        $message_title = "Resume Automatic"
        $message_content = "Indicates that the computer has awakened in response to an event"
EndSwitch

MsgBox (0, $message_title, $message_content)

Share this post


Link to post
Share on other sites

Very good, thanks

but I want to know how to block the standby/hibernate after detected the event?

Anything else?

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0