closing windows Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
awcrt9316
Posts: 61
Joined: 03 Mar 2020, 20:06

closing windows

28 Apr 2020, 23:56

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
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: closing windows

29 Apr 2020, 00:57

Can't see why :arrow: WinClose's ahk_group wouldn't match your condition?!
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
awcrt9316
Posts: 61
Joined: 03 Mar 2020, 20:06

Re: closing windows

29 Apr 2020, 11:52

@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.
User avatar
littlegandhi1199
Posts: 187
Joined: 29 Aug 2016, 23:58

Re: closing windows  Topic is solved

29 Apr 2020, 13:58

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
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285

Return to “Ask For Help”

Who is online

Users browsing this forum: anv, Bing [Bot], effel, JAutohotkey, mikeyww, return, teadrinker and 51 guests