Sign in to follow this  
Followers 0
Raik

capture poweroff via powerbutton

10 posts in this topic




My first idea is to try hyperterminal to see if the power button kicks back an ascii character or code. I dont have an IBM laptop to try it on and really hyperterminal might not even do this.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

Messages "endsession" and "queryendsession" are sent at shutdown...maybe they are also sent at powerdown, don't know.

You can setup a test fairly easily, see doc for guiregistermsg.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

What is it you're looking to do? Your power button behavior can be changed within Windows. I assume you have yours setup as "Shutdown" and you want to execute a script at that point?

You can run scripts at shutdown via group policy. Scripts (Startup/Shutdown) under Windows Settings. During the shutdown process Windows will run the script but this is after the closing of running apps/Explorer. So might not be what you're looking for.

If you want it to run before then, i'm not too familar with that, but kylomas post sounds like good advice.

Share this post


Link to post
Share on other sites

Just remember, as far as I know of, there's nothing that a Windows app can do to stop the user from pressing and holding the power button for 4 seconds to power down the computer.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

thats the point.

i want to use this 4 seconds to alert about the thief.

as far as i know, on some desktops windows will stutdown, if this key is pressed for about two seconds. so there must be some signal.

EDIT:

in WinXP if i set action on powerbutton to "ask what to do". this box pops up immediately.

maybe there is no keycode but something like acpi-event must be there.

Edited by Raik

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Share this post


Link to post
Share on other sites

I don't think this is ever going to work.

If you press the power button and let go then you should be able to pick it up if windows is set to power down on power button.

However if someone presses and holds the power button I don't think Windows knows anything about this, the power is killed you even hear the click of the hard drive so that doesn't get stopped nicely either.

If there is another PC available I would use TCPIP and if communication is lost by either PC then get the other one to send an alert.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

raik,

see this link. Its a VB forum but addresses your question.

http://www.vbforums.com/showthread.php?t=531254

kylomas

P.S. sorry, don't know how to supply a url link.

EDIT: opps, guess the editor does it for you.

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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