Jump to content

Recommended Posts

Posted

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

Posted

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.

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

  Reveal hidden contents

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

Posted (edited)

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
Posted
  On 9/9/2013 at 2:03 PM, Mat said:

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 ?

Posted (edited)

  On 9/9/2013 at 2:11 PM, Alexxander said:

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
Posted
  On 9/9/2013 at 1:37 PM, Alexxander said:

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?

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

  Reveal hidden contents

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

Posted

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

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

  Reveal hidden contents

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

Posted

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

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

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
  • Recently Browsing   0 members

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