Page 1 of 1

closing windows

Posted: 28 Apr 2020, 23:56
by awcrt9316
Why does a shutdown option appear with my script? I am trying to close all current windows. Also, is it possible for me to close a window by title if it isn't the active window?
I looked at the documentation and these things below under winclose don't seen to correspond to the name of the website, such as https://google.com. I would like to close all google.com's for example.

ahk_class
ahk_id
ahk_pid
ahk_exe
ahk_group

Code: Select all

#SingleInstance, force
^z::
WinGet, OutputVar, List
msgbox, % outputvar
a := 1
loop, % outputvar
{
if winexist("ahk_id" . outputvar%a%)
winkill
a++
}


looking through documentation more, I found this: SetTitleMatchMode RegEx

not sure how to use it though

Re: closing windows

Posted: 29 Apr 2020, 00:57
by BNOLI
Can't see why :arrow: WinClose's ahk_group wouldn't match your condition?!

Re: closing windows

Posted: 29 Apr 2020, 11:52
by awcrt9316
@BNOLI The script works absolutely fine, all the windows close, except there is a shutdown option that appears at the end for some reason every time. Just wondering if this is a bug or not.

Re: closing windows  Topic is solved

Posted: 29 Apr 2020, 13:58
by littlegandhi1199
You didn't specify they needed google in the title so it found all of them.

EDIT: ahh I see now you did want to close ALL windows. I'll check that one second
EDIT: You've got to make sure first off you're not trying to kill windows with no title

Code: Select all

#SingleInstance, force

^z::
WinGet, OutputVar, List
msgbox, %outputvar% windows found!
loop, % outputvar
{
outID := outputvar%A_Index%
WinGetTitle, outTitle, ahk_id %outID%
If (outTitle != "")
{
if winexist("ahk_id" . outID)
	winkill
}
}
return
But then... if you take a look at my list of window titles (after ignoring the blank ones) there is a window called "Start" and one called "Program Manager"
Spoiler
I would check yours as well and then blacklist those 2 from the kill command if you get the same results

If ((outTitle != "") && (outTitle != "Start") && (outTitle != "Program Manager"))







Moving onto your google stuff the 4th paramter of WinGet is an optional title name which has to be somewhere in the title
WinGet, OutputVar, List, Google



However tabs are not windows though...You can't close different tabs like you can different windows.

If that's what you are trying to do then...
Pressing Ctrl+Shift+Tab goes backwards through all your open tabs and Ctrl+Tab goes forwards 1 at a time

Pressing Ctrl+W closes the current tab