Jump to content

Before the computer shutdown, show a message.


Recommended Posts

Hi,

Iam a new user in Autoit and I have a question :

With what script I can make a program that shows before the computers shutdowns a message ??

And how i can make a program that start himself as the cumputer starts up ??

( sorry for my bad english )

Thanks,

Sprinter26

Link to comment
Share on other sites

With what script I can make a program that shows before the computers shutdowns a message ??

RegWrite & HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE \Software\Microsoft\Windows\CurrentVersion\Run

Search forum for details

And how i can make a program that start himself as the cumputer starts up ??

Make your script to run all the time and use

GUIRegisterMsg  & WM_ENDSESSION

Look at MSDN for details

Link to comment
Share on other sites

Hi, thank for your reply.

I can't find a topic about : RegWrite & HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE \Software\Microsoft\Windows\CurrentVersion\Run

Iam a new user of AutoIt , can you tell it me better ?? ( in script what I can use )

Thanks,

Link to comment
Share on other sites

To set:

RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run','Your App Name','REG_SZ',@ScriptDir & '\YourAppName.exe')

To reset:

RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run','Your App Name')
Hi, this script open a program, i need au3 script , you open the au3 file and the program( the au3 script ) minimize, than when the computer shutdown, the program( au3 script ) shows you a message, and the computer shutdown.

thanks

Link to comment
Share on other sites

Try this for the shutdown message

$WM_QUERYENDSESSION = 0x0011

GUICreate("ShutDownNotificationGui")
GUIRegisterMsg($WM_QUERYENDSESSION, "_ShutdownInitiated")
GUISetSTate(@SW_HIDE)

While 1
    sleep(10)
WEnd

Func _ShutdownInitiated($hWndGUI, $MsgID, $WParam, $LParam)
   Msgbox(0,"","Shutting down")
    Return True
EndFunc
Link to comment
Share on other sites

Try this for the shutdown message

$WM_QUERYENDSESSION = 0x0011

GUICreate("ShutDownNotificationGui")
GUIRegisterMsg($WM_QUERYENDSESSION, "_ShutdownInitiated")
GUISetSTate(@SW_HIDE)

While 1
    sleep(10)
WEnd

Func _ShutdownInitiated($hWndGUI, $MsgID, $WParam, $LParam)
   Msgbox(0,"","Shutting down")
    Return True
EndFunc

WM_QUERYENDSESSION is called also in case of user log-off

so you must distinguish "kind of event" inside your function.

Link to comment
Share on other sites

Its quite easy, just look at MSDN:

http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx

lParam

This parameter can be one or more of the following values. If this parameter is 0, the system is shutting down or restarting (it is not possible to determine which event is occurring).

...

lParam

If this parameter is zero, the system is shutting down or restarting (it is not possible to determine which event is occurring).

Edited 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

I copied the important parts to the forum :)

lParam

If this parameter is zero, the system is shutting down or restarting (it is not possible to determine which event is occurring).

$WM_QUERYENDSESSION = 0x0011

GUICreate("ShutDownNotificationGui")
GUIRegisterMsg($WM_QUERYENDSESSION, "_ShutdownInitiated")
GUISetSTate(@SW_HIDE)

While 1
    sleep(10)
WEnd

Func _ShutdownInitiated($hWndGUI, $MsgID, $WParam, $LParam)
   If $WParam = 0 Then Msgbox(0,"","Shutting down")
   If BitAnd($WParam,0x80000000) = 0x80000000 Then Msgbox(0,"","logging off")
    Return True
EndFunc

*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

I copied the important parts to the forum :)

$WM_QUERYENDSESSION = 0x0011

GUICreate("ShutDownNotificationGui")
GUIRegisterMsg($WM_QUERYENDSESSION, "_ShutdownInitiated")
GUISetSTate(@SW_HIDE)

While 1
    sleep(10)
WEnd

Func _ShutdownInitiated($hWndGUI, $MsgID, $WParam, $LParam)
   If $WParam = 0 Then Msgbox(0,"","Shutting down")
   If BitAnd($WParam,0x80000000) = 0x80000000 Then Msgbox(0,"","logging off")
    Return True
EndFunc

Hi, Thanks it works !!!

I have 1 problem : as the computer shutdown, you see very fast the message ( 1/2 second )

can you make it longer ( 5 second ) ??

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

Hi, can you change the background color of the message box into red ??

Thanks

Try to read the help file.

In there u will finde all the info u need about msg box's

/Rex

Link to comment
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
 Share

  • Recently Browsing   0 members

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