how to close all the browsers in a group? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

how to close all the browsers in a group?

Post by hancre » 18 Sep 2021, 20:25

I think this following script should close all the browsers.
But it' doesn't work.
How can I make the grouped browsers closed by this script, keeping other programs?

Code: Select all

GroupAdd, browsers, ahk_class IEFrame
GroupAdd, browsers, ahk_class whale
GroupAdd, browsers, ahk_class chrome
GroupAdd, browsers, ahk_class edge
WinClose, browsers
return


Thanks for any help in advance.
Last edited by hancre on 19 Sep 2021, 23:08, edited 1 time in total.
Ianizer
Posts: 79
Joined: 07 Mar 2021, 00:06

Re: how to close all the browsers in a group?

Post by Ianizer » 18 Sep 2021, 20:42

All you need is ahk_group:

Code: Select all

GroupAdd, browsers, ahk_class IEFrame
GroupAdd, browsers, ahk_class whale
GroupAdd, browsers, ahk_class chrome
GroupAdd, browsers, ahk_class edge
WinClose, ahk_group browsers
return
hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: how to close all the browsers in a group?

Post by hancre » 18 Sep 2021, 21:05

Ianizer wrote:
18 Sep 2021, 20:42
Thanks for your tip. But it doesn't work. @.@
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: how to close all the browsers in a group?  Topic is solved

Post by mikeyww » 18 Sep 2021, 21:19

Code: Select all

GroupAdd, browser, ahk_exe chrome.exe
GroupAdd, browser, ahk_exe msedge.exe
WinClose, ahk_group browser
hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: how to close all the browsers in a group?

Post by hancre » 18 Sep 2021, 21:42

mikeyww wrote:
18 Sep 2021, 21:19
Thank you for your help.
Although it doesn't close chrome, it's useful. ^^;;

I looked up the information on chrome by window spy. What should I do?
New Tab - Google Chrome
ahk_class Chrome_WidgetWin_1
ahk_exe chrome.exe
ahk_pid 2592

Can I have another question? ^^
I thought I had to add <return> at the end.
but it doesn't work with <return>.
do you know the reason?
User avatar
Xtra
Posts: 2744
Joined: 02 Oct 2015, 12:15

Re: how to close all the browsers in a group?

Post by Xtra » 18 Sep 2021, 22:00

Try running your script as admin to close Chrome.
hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: how to close all the browsers in a group?

Post by hancre » 18 Sep 2021, 22:27

Xtra wrote:
18 Sep 2021, 22:00
How can I do it?
This script runs automatically system startup.
hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: how to close all the browsers in a group?

Post by hancre » 19 Sep 2021, 00:01

Xtra wrote:
18 Sep 2021, 23:42
Thanks a lot for your help.
following your tip, It works after adding this code. :

Code: Select all

SetWorkingDir %A_ScriptDir%
if not A_IsAdmin
	Run *RunAs "%A_ScriptFullPath%" ; (A_AhkPath is usually optional if the script has the .ahk extension.) You would typically check  first.
Post Reply

Return to “Ask for Help (v1)”