Jump to content
Sign in to follow this  
sprinter26

Before the computer shutdown, show a message.

Recommended Posts

sprinter26

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

Share this post


Link to post
Share on other sites
covaks

For your first question, you can do this in gpedit.msc. Windows Settings > Scripts.

Your second question is answered in the FAQ. Q11

Share this post


Link to post
Share on other sites
sprinter26

Hi, yes that works but it is not in Autoit v3 , and I want to make in in Autoit V3.

Thanks for your fast reply.

Share this post


Link to post
Share on other sites
Zedna

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

Share this post


Link to post
Share on other sites
sprinter26

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,

Share this post


Link to post
Share on other sites
Zedna

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')

Share this post


Link to post
Share on other sites
sprinter26

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

Share this post


Link to post
Share on other sites
ChrisL

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

Share this post


Link to post
Share on other sites
Zedna

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.

Share this post


Link to post
Share on other sites
ProgAndy

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

Share this post


Link to post
Share on other sites
ProgAndy

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

Share this post


Link to post
Share on other sites
sprinter26

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

Share this post


Link to post
Share on other sites
sprinter26

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

Thanks

Share this post


Link to post
Share on other sites
Rex

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

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  

×