Jump to content
Sign in to follow this  
Hawkwing

Start script when you click shutdown button?

Recommended Posts

Hawkwing

Is there a way to start a script when I click Start\Shutdown?


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites
somdcomputerguy

Maybe this is what you need?

; terminate a script right [i]before[/i] a user shuts
; VicTT
; DllCall("Kernel32", "ubyte", "SetProcessShutdownParameters", "dword", 0x400, "dword", 0x000)

Global $WM_QUERYENDSESSION = 0x0011
Func InterceptShutdown($hWnd, $msg, $w, $l)
    MsgBox(0, "", "Shutting down")
EndFunc  ;==>InterceptShutdown
GUIRegisterMsg($WM_QUERYENDSESSION, "InterceptShutdown")
While 1
    Sleep(10)
WEnd

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Hawkwing

Nope, that just makes a msgbox AFTER I have shutdown, which means it is too late to have the script really do anything. I was wandering if there was a way to have a script run when you click the button that brings up the gui asking you to shutdown (I guess the first post was kind of deceiving since I asked to start a script after you clicked shutdown).


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites
Juvigy

Do you see this part?

While 1
    Sleep(10)
WEnd

Put in the loop what you want to do. It will be executed before the actual shutdown of the system.

Share this post


Link to post
Share on other sites
Hawkwing

But if it takes too long won't the computer shutdown before its finished?


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites
Juvigy

No

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  

×