adom Posted March 15, 2012 Share Posted March 15, 2012 (edited) Hi Manko, I have done several tests. Now I can say in every case the Tray Icon is present and you click one time on it the registered canceling of shutdown is gone. Even when I tried to combine a GUISWITCH after MouseUp or MouseClick by Tray Icon-Event to give the receivement back to Main-GUI. The same in case of having a viewable GUI which Window is minimized. Remark: Userdefined Messages defined by _WinAPI_RegisterWindowMessage($iWin_msg_reg_num) are NOT affected. Solution: Build a separate EXE which has a hidden window to catch the Queryendmessage and send a userdefined message to my Main GUI to get the state. OS = Vista SP2 Edited March 15, 2012 by adom Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
Manko Posted March 16, 2012 Share Posted March 16, 2012 (edited) This is the other thread:He got it working the way he wanted. The interesting thing I thought you should have a look at is the options he sets in the beginning of the code. ...there is an option to disable the autopause which happens when you interact with the tray... ?The trayoneventmode was also interesting...Might solve things!? check it out!/Manko Edited March 16, 2012 by Manko Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually... Link to comment Share on other sites More sharing options...
adom Posted March 16, 2012 Share Posted March 16, 2012 (edited) Hi Mnko,yes indead I just see what I can learn from that script. Thank you for that hint!I will do an test withAutoItSetOption("TrayAutoPause","0") and report.Greetings Andrew Edited March 16, 2012 by adom Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
adom Posted March 17, 2012 Share Posted March 17, 2012 (edited) Hi Manko,tried with option AutoItSetOption("TrayAutoPause","0"). --> Same problem. 1 click on TrayIcon and shutdown deflection is gone. Btw I have setted some Menue items to the Tray Icon before. Ref to Autoit Help with Menue Items there is no AutoPause. So I think by that way also in my former tests were no AutoPause.OK so far. I move on with my workaraound using a separate Shutdown Deflector GUI set to hidden and no Tray Icon (#NoTrayIcon).For people are interested in a solution, the 2 scripts postet by t_bear (http://www.autoitscript.com/forum/topic/...on-winxp/page__view__findpost_) can be helpful.Greetings Andrew Edited March 17, 2012 by adom Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
adom Posted March 21, 2012 Share Posted March 21, 2012 Hi Manko, last more question: is there a possibility to differ if the shutdown message comes from a Restart or from a Shutdown? Greetings Andrew Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
adom Posted March 22, 2012 Share Posted March 22, 2012 Someone here who can hear me? Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
Yashied Posted March 22, 2012 Share Posted March 22, 2012 is there a possibility to differ if the shutdown message comes from a Restart or from a Shutdown?No. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
adom Posted March 22, 2012 Share Posted March 22, 2012 Thx Yashied. But Windows should have a Flag for restarting. I know that Win must write a flag into BIOS to tell the Hardware to restart. But is there any entry in Registry that System will be restarted? Or: Can it be a way to write a Dummy script which write a Flag in an ini or registry when it receive a resart flag if win has one? Greetings Andrew Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
adom Posted March 23, 2012 Share Posted March 23, 2012 Hi everybody , does anybody know, how windows post a flag or something else in Registry so signal that Shutdown was intended as RESTART? Greetings Andrew Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
BrewManNH Posted March 23, 2012 Share Posted March 23, 2012 I'm pretty sure that there's no registry setting being changed when the OS tells the computer to reboot. It's all done in the software itself, there's no need for an external flag, the OS logs off and shuts down, but sends a signal to the motherboard that it is rebooting and the computer reboots. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
adom Posted March 23, 2012 Share Posted March 23, 2012 THX to BrewManNH. I am going on to investigate. Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
adom Posted April 3, 2012 Share Posted April 3, 2012 Finaly I handle it with a GUI-Decision of User what he wants to do after a shutdown Query is received. Thanks! :bye: Greetings Andrew Link to comment Share on other sites More sharing options...
MDCT Posted January 23, 2016 Share Posted January 23, 2016 (edited) Hi guys, I'm going to ask here my problem as it seems relevant to the subject. What I need is a script that...when Windows is shutting down, it can clean-shutdown an application, wait for the wrapper process to not exist then resume the windows shutdown. The reason is: I'm running portable applications on my computer. These portable applications use wrapper to make the application portable, the wrapper would copy settings to the computer and run the application, it then will monitor if the application is closed. And if the application is closed, the wrapper will copy back to the application folder, and clean the computer. The problem: The problem comes when I shutdown the computer. When I shutdown the computer, the system always close the wrapper first, thus, the settings are not saved back to the application folder. I search for a solution to make sure the wrapper to be the last to be closed by the system shutdown. However, I think the only solution is to catch system shutdown, clean-close the application, the wrapper then will notice the application is closed and does its thing. So far, I have done is: #Include <ButtonConstants.au3> #Include <GUIConstantsEx.au3> #Include <WinAPIEx.au3> #NoTrayIcon Opt('MustDeclareVars', 1) If _WinAPI_GetVersion() < '6.0' Then MsgBox(16, 'Error', 'Require Windows Vista or later.') Exit EndIf Global $hForm, $Msg $hForm = GUICreate('MyGUI', 0,0) GUIRegisterMsg(0x0011, 'WM_QUERYENDSESSION') ; Set the highest shutdown priority for the current process to prevent closure the other processes. _WinAPI_SetProcessShutdownParameters(0x03FF) _WinAPI_ShutdownBlockReasonCreate($hForm, 'Clean Closing Applications...') While 1 $Msg = GUIGetMsg() WEnd Func WM_QUERYENDSESSION($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hForm If _WinAPI_ShutdownBlockReasonQuery($hForm) Then RunWait("AutoIt3 WinShutdown.au3", "", @SW_HIDE) Return 0 EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_QUERYENDSESSION WinShutdown.au3 is the script to do clean close to the application. The RunWait will not run on system shutdown. However, if I put script in it, it can run. For example: Local $WHnd = WinGetHandle("MozillaWindowClass", "") WinClose ($WHnd) For $i = 1 To 2 Step 0 Sleep(64) If ProcessExists("FirefoxPortable.exe") Then ; Check to make sure the wrapper done saving settings WinClose ($WHnd) Else ExitLoop EndIf Next Does it mean that I cannot run a script on windows shutdown? Is there any better solution to my problem, for example making sure the wrapper to be closed last on windows shutdown? Thank you [EDIT:] Now I think I know why I cannot run a script on shutdown. I believe, because the parent script needs to be on elevated or Admin mode in order to run another script on shutdown. I guess, this should cover my problem. Edited January 23, 2016 by MDCT Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now