VAN0 Posted February 27, 2021 Posted February 27, 2021 Hello. Is there a way send shutdown command to a running process? There are many intercept shutdown scripts, so I wonder if there is a way fake shutdown message and send it only to a specific process? The process in question has no window, but has tray icon without menu. Thank you.
Developers Jos Posted February 27, 2021 Developers Posted February 27, 2021 Try WinClose() on the main menu. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
VAN0 Posted February 27, 2021 Author Posted February 27, 2021 (edited) Thank you. It worked, but for some reason it "kills" the process, not gracefully shut it down... Edited February 27, 2021 by VAN0
Developers Jos Posted February 27, 2021 Developers Posted February 27, 2021 How have you determined that as this is simply a Windows message being send to the Window and is the way to tell the application to gracefully close? It is not like ProcessClose() which actually does hard kill the task. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
VAN0 Posted February 27, 2021 Author Posted February 27, 2021 (edited) Well, when the application is killed via task manager or via winclose() the next time it started, it changes settings to default, when it closed gracefully via exit in tray menu (I lied about not having tray menu, because I don't want to use it), next time it launches it restores the settings. This is what I've used: Local $aProcessList = ProcessList("lcore.exe") Local $aWinlist = Winlist() For $i = 1 To $aProcessList[0][0] For $j = 1 To $aWinlist[0][0] If WinGetProcess($aWinlist[$j][1]) = $aProcessList[$i][1] Then ConsoleWrite("WinClose PID[" & $aProcessList[$i][1] & "] HWND[" & $aWinlist[$j][1] & "]: " & WinClose($aWinlist[$j][1]) & @CRLF) EndIf Next Next Edited February 27, 2021 by VAN0
Developers Jos Posted February 27, 2021 Developers Posted February 27, 2021 Ok, so guess you have the same issue when you hit the X at the right top of the window? Anyways, it is the Application not handling this correctly so you probably need to send the Exit option message to the window with WinMenuSelectItem(). SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
VAN0 Posted February 27, 2021 Author Posted February 27, 2021 (edited) It doesn't have any GUI window that can close the application, just tray icon. The reason why I don't want use tray menu, is because sometimes the application is not responding to right click, I was hoping it's not completely frozen and can still receive and handle shutdown commands. When it "freezes" and than system goes into reboot the application starts normally with all settings restored, so my hypotheses it's still responding to system's shutdown message. Edited February 27, 2021 by VAN0
Developers Jos Posted February 27, 2021 Developers Posted February 27, 2021 So this is your own application you want to close? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
VAN0 Posted February 27, 2021 Author Posted February 27, 2021 no, external application that giving me hard time, want create a script to restart it with a hotkey
Developers Jos Posted February 27, 2021 Developers Posted February 27, 2021 (edited) Ok, so that external application still responds to the "Windows is shutting down" message but doesn't respond to the trayicon. You could try sending the .. to the app: #include <WindowsConstants.au3> $hWnd=WinGetHandle('your program window') _SendMessage($hWnd, $WM_QUERYENDSESSION) ... maybe that works but haven't tested it. Edited February 27, 2021 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Developers Jos Posted February 27, 2021 Developers Posted February 27, 2021 (edited) Tested this on SciTE and seems to be working fine: #include <SendMessage.au3> #include <WindowsConstants.au3> $hWnd=WinGetHandle('[CLASS:SciTEWindow]') _SendMessage($hWnd, $WM_QUERYENDSESSION) Edited February 27, 2021 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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