Closing a specific website script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ener555

Closing a specific website script

Post by ener555 » 03 Feb 2016, 06:17

Hello everyone,

Hope you can help. Might be pretty easy for some of you.

I am trying to close an Internet Explorer Window with a specific URL e.g. http://www.google.com and only this particular Internet Explorer Window while leaving other ones open.


Additional info (not sure if they are necessary)

I have several Internet Explorer windows open
The Internet Explorer window that needs to be closed has no additional tabs just the http://www.google.com
The Internet Explorer window that needs to be closed is most likely not the active window


I know I could just kill Iexplorer.exe but that would kill all the windows, not just the one with http://www.google.com

I would appreciate any help.

Thanks.

User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Closing a specific website script

Post by Blackholyman » 03 Feb 2016, 10:33

Before going down the long way

Have you tried winClose with the wintitle as show by winSpy?

WinSpy come's with the autohotkey install
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:

timelizards
Posts: 20
Joined: 11 Sep 2015, 21:00

Re: Closing a specific website script

Post by timelizards » 05 Feb 2016, 01:49

Code: Select all

IECloseExcept("https://www.google.com/?gws_rd=ssl",true)

IECloseExcept("www.google.com")

IECloseExcept(url, exact := "")
{
	if ( exact == true )
	{
		For wb in ComObjCreate( "Shell.Application" ).Windows
		{
			;msgbox % "LocationURL = " . wb.locationurl . "`nFull Name = " . wb.fullname . "`nurl = " . url
			if InStr( wb.FullName, "iexplore.exe" )
			{
				if (wb.locationurl = url)
				{
					;msgbox % wb.locationurl
					continue
				}
				else
					wb.quit()
			}
		}
	}
	else
	{
		For wb in ComObjCreate( "Shell.Application" ).Windows
		{
			;msgbox % "LocationURL = " . wb.locationurl . "`nFull Name = " . wb.fullname . "`nurl = " . url
			if InStr( wb.FullName, "iexplore.exe" )
			{
				if instr(wb.locationurl, url)
					continue
				else
					wb.quit()
			}
		}
	}
}
Last edited by timelizards on 05 Feb 2016, 01:56, edited 2 times in total.

timelizards
Posts: 20
Joined: 11 Sep 2015, 21:00

Re: Closing a specific website script

Post by timelizards » 05 Feb 2016, 01:55

credits to jethrow for the ieget function which i probably butchered to make this. i use something like this but not exactly for my own needs

Post Reply

Return to “Ask for Help (v1)”