Page 1 of 1

Get domain from email address

Posted: Jun 11th, ’19, 17:47
by vrod5454
Hi,

How can I grab the domain from an email address (via input box) and open that domain in a browser? My input will always be an email address. So in the input box I type

Code: Select all

who foobar@somedomain.com
I am using the code below to search for the email address using google. I would like to add code that will also open a new tab and go to the domain (website). So using the example above it would be somedomain.com

Code: Select all

InputBox, Input, Meta search, Prefixes: g`, who`,  ,250, 250
DivPos:=InStr(Input, " ")
Prefix:=SubStr(Input, 1, DivPos-1)
SearchText:=SubStr(Input, DivPos+1)
StringReplace, SearchText, SearchText, %A_Space%, `%20, All
StringReplace, SearchText, SearchText, #, `%23, All
SearchText:=Trim(SearchText)
if (Prefix="g")
{
	//Do something.
}
else if (Prefix="who")
{
	Run, "www.google.com/search?hl=en&q=%SearchText%" //open browser and searches google for the email address
	Run, "%SearchText%" //should open a new tab browser and go to the URL
}
return

Thanks for your help.

Re: Get domain from email address

Posted: Jun 12th, ’19, 19:58
by Tom

Code: Select all

StringTrimLeft, domain, input, % InStr(input, "@")
run % "www." domain
;)

Re: Get domain from email address

Posted: Jun 20th, ’19, 15:45
by vrod5454
Thanks Tom.

For future readers, I changed the run line to:

Code: Select all

Run, "www.%domain%"

Re: Get domain from email address

Posted: Jul 4th, ’19, 13:03
by Marko
or

Code: Select all

Run www.%domain%