Exit all apps

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Exit all apps

Post by SimPlayer » 17 May 2022, 15:29

Hi guys.

Now, is it possible to exit all open apps from one app?

I´m running a slideshow, and during that time it runs (one time information) I can´t seem to be able to stop the script,(only if I loop it) so I started another script at the same time that has the stop code. From that script I should be able to exit all apps, than everything would be fine,
so, is that possible??

SimPlayer

User avatar
mikeyww
Posts: 26598
Joined: 09 Sep 2014, 18:38

Re: Exit all apps

Post by mikeyww » 17 May 2022, 17:24

Code: Select all

exitAllOpenApps() { ; https://www.autohotkey.com/boards/viewtopic.php?p=462766#p462766
 WinGet, winArray, List                                        ; Get all windows
 Loop, %winArray% {
  WinGet, winStyle, Style, % winTitle := "ahk_id" winArray%A_Index%
  WinGetTitle, ttitle, %winTitle%
  If (winStyle & 0x10000000 && ttitle)                         ; Window is visible & has a title
   If ttitle not in Program Manager,MainWindow,Start,Windows Task Manager
    WinClose, %winTitle%
 }
}

SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Re: Exit all apps

Post by SimPlayer » 18 May 2022, 01:28

Hi

Thanks man, I´ll give it a try!

SP

SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Re: Exit all apps

Post by SimPlayer » 18 May 2022, 01:58

Hi

Nope, it didn´t work att all, I don´t know if we understand each other this time.

I want to close a specific script by a code line in another script. There´s a post on this but I don´t get that either, viewtopic.php?t=75425

SimPlayer

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Exit all apps

Post by WalkerOfTheDay » 18 May 2022, 04:27

Try: (not my code someone gave it to me a couple of year ago, don't know who to credit for it anymore :? )

Code: Select all

DetectHiddenWindows, On 
	WinGet, List, List, ahk_class AutoHotkey 

	Loop %List% 
	  { 
		WinGet, PID, PID, % "ahk_id " List%A_Index% 
		If ( PID <> DllCall("GetCurrentProcessId") ) 
			 PostMessage,0x111,65405,0,, % "ahk_id " List%A_Index% 
	  }

User avatar
mikeyww
Posts: 26598
Joined: 09 Sep 2014, 18:38

Re: Exit all apps

Post by mikeyww » 18 May 2022, 05:11

What my posted script does:
From that script I should be able to exit all apps.
Closing a specific script is simple in two lines: use :arrow: WinClose. The window title to specify is the full path to the script. Before the WinClose line, add DetectHiddenWindows, On.

Code: Select all

DetectHiddenWindows, On
WinClose, D:\temp2\temp.ahk ahk_class AutoHotkey
I added the window class here just as an additional option. This would distinguish this window from others that may have similar window titles.

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Exit all apps

Post by boiler » 18 May 2022, 05:22

@SimPlayer — When you implemented mikeyww’s code in his first post, did you add a call to that function in your script? If you simply place that function in your script, it doesn’t execute without you adding a call to it.

User avatar
mikeyww
Posts: 26598
Joined: 09 Sep 2014, 18:38

Re: Exit all apps

Post by mikeyww » 18 May 2022, 05:35

Very good point, boiler! Sorry I forgot to mention that specifically. :)

SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Re: Exit all apps

Post by SimPlayer » 18 May 2022, 07:56

Hi

Ok, thanks again guys, I'll give it another try.

SimPlayer

Post Reply

Return to “Ask for Help (v1)”