Jump to content
Sign in to follow this  
Alexxander

Turn off monitor when shutdown button pressed from start menu

Recommended Posts

Alexxander

Hi 

i had made a thread before this 

'?do=embed' frameborder='0' data-embedContent>>

it is pretty much the same idea if a moderator is here please delete that 1

i want to make  script that when i open start menu a button shows on top windows shutdown button

when i click the Autoit button a mntroff.exe will be executed 

montroff.exe is a app the turn off the PC monitor

i had tried a lot to find another way to turn off the monitor when the shut down button is presses but with no luck, i tried to interrupt the win 7 shutdown then turn off monitor also with no luck

so now i'm trying this trick but im having some problems on my notepad example: the button was flashing but  working but now (when dealing with start menu) the button is flashing and not working  i think it is because of the start menu it is not like a normal window

 

here is what i tried 

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

$GUI = GUICreate("MY GUI", 93,22,267,686, $WS_POPUP , $WS_EX_TOPMOST)
$but = GUICtrlCreateButton("", -1, -1, 500, 500)
guisetstate()



While 1
    $nMsg = GUIGetMsg()
    WinSetOnTop($GUI, "", 1)
    $menu = WinExists("Start menu", "All Programs")
    if $menu = 1 then GUICtrlSetState($but, $GUI_SHOW)
    if $menu = 0 then GUICtrlSetState($but, $GUI_HIDE)
    If $nMsg = $but Then ShellExecute("C:\auto\mntroff.exe")
WEnd

as i said this code is working but not with start menu 

i have no problem if it is flashing but when i press the button the mntroff.exe is not executed


Share this post


Link to post
Share on other sites
TheSaint

Is this because your monitor does not automatically shutdown when your PC does?

If that is the case, then you could just write a Shutdown script with a shortcut on your Desktop, that runs mntroff.exe before the shutdown command. You just double-click the shortcut to get both happening, with no need to involve Start Menu at all.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
Alexxander
TheSaint

 

Ok nice idea but i was struggling with this code for 5 hours i cant get it to work please try it on  your PC

i'm getting crazy i want to find why it is not working 


Share this post


Link to post
Share on other sites
Mat

Very difficult for me to reproduce effectively here. You are right that in a lot of cases the start menu is a little bit different to normal windows. Try making the parent of the GUI the start menu, and also look at what styles the start menu has (this can be done from the window info tool, and looking at the bits that are set).

There are several better methods for doing what you want. The best would be to actually get your program to handle the shutdown itself, rather than looking for the button press. Google for examples, there may not be that many in AutoIt, AbortSystemShutdown is the one function you need, either WM_QUERYENDSESSION or WM_ENDSESSION can be used to see if the system is shutting down.

In most cases the best solution would be to use WM_QUERYENDSESSION and return 0 from that, and then turn off the monitor.

Edit: Just tried to shut down with a script running that returned zero from WM_QUERYENDSESSION. It closed down all the applications I had running, including the script itself, but then didn't shutdown. That's just as likely to be windows playing up as the script actually working. I'll experiment a bit more later.

Edited by Mat

Share this post


Link to post
Share on other sites
Alexxander

Very difficult for me to reproduce effectively here. You are right that in a lot of cases the start menu is a little bit different to normal windows. Try making the parent of the GUI the start menu, and also look at what styles the start menu has (this can be done from the window info tool, and looking at the bits that are set).

There are several better methods for doing what you want. The best would be to actually get your program to handle the shutdown itself, rather than looking for the button press. Google for examples, there may not be that many in AutoIt, AbortSystemShutdown is the one function you need, either WM_QUERYENDSESSION or WM_ENDSESSION can be used to see if the system is shutting down.

In most cases the best solution would be to use WM_QUERYENDSESSION and return 0 from that, and then turn off the monitor.

Edit: Just tried to shut down with a script running that returned zero from WM_QUERYENDSESSION. It closed down all the applications I had running, including the script itself, but then didn't shutdown. That's just as likely to be windows playing up as the script actually working. I'll experiment a bit more later.

 

bro we had disscussed this here

im finding it so complicated and im new to autoit

please can u just find out what is happening with win 7 start menu ?


Share this post


Link to post
Share on other sites
FireFox

im finding it so complicated and im new to autoit

Don't do what you can't do.

Try to build something by googling/forum search, that's the best you can do.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
TheSaint

TheSaint

Ok nice idea but i was struggling with this code for 5 hours i cant get it to work please try it on  your PC

i'm getting crazy i want to find why it is not working 

I see no benefit in trying to do it the complex way your are, when a simple shortcut on your desktop is quicker and easier.

In fact, all my PC's use that idea, which is simpler for me, because I don't have a Monitor issue, so I just use a variation of -

C:WindowsSystem32shutdown.exe /s /f /t 9

with a simple shortcut, no script.

Why do you need to use the Start Menu approach?

Have you looked at Shutdown in the Help file?


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
Mat

Or you could replace shutdown.exe. Or you could wait for the shutdown.exe process and kill it before it kills you. 

There are many ways to skin a cat. Trying to entice it through a blender with a toy mouse is not necessarily the best way.

  • Like 1

Share this post


Link to post
Share on other sites
TheSaint

And Mat ought to know, a Cat sat on him once .... but that's another ditty!  :muttley:


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
careca

I would try to scan processes for shutdown.exe, and uppon processexists = true, turn off monitor, haven't tried, not sure it would work.


Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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  

×