MAC Address Vendor ID

Post your working scripts, libraries and tools for AHK v1.1 and older
Bkid
Posts: 31
Joined: 13 Jun 2014, 12:19

MAC Address Vendor ID

Post by Bkid » 31 Jan 2015, 13:51

As per my habit of making little niche scripts here and there, I present the MAC Address Vendor Identifier! It basically pulls info from a website to tell you the manufacturer of the NIC in a piece of equipment.
Not tested very much, but it seems to work fine so far.

So..here it is. :D

Code: Select all

#SingleInstance, Force
#NoEnv

Gui, Add, Text, x0 w215 Center, Enter the first six characters or full MAC.
Gui, Add, Text, x10 y+10 w68 h12, Modem MAC:
Gui, Add, Edit, x+2 yp-3 w125 gCheckMACLen vMAC Limit17
Gui, Add, Text, x10 y+7 w68 h12, Vendor:
Gui, Add, Edit, x+2 yp-3 w125 ReadOnly vVendor
Gui, Add, Button, x10 y+7 w195 vSearchBtn gSearch, Search
Gui, Show, w215, MAC Vendor ID
GuiControl, Disable, SearchBtn
Return

CheckMACLen:
Gui, Submit, NoHide
StringReplace, MAC, MAC, %A_Space%,, All
Len := (StrLen(MAC))
If MAC
	GuiControl, Enable, SearchBtn
Else
	GuiControl, Disable, SearchBtn
If Len in 6,8,12,17
	GuiControl, Enable, SearchBtn
Else
	GuiControl, Disable, SearchBtn
Return

Search:
Gui, Submit, NoHide
Tout = 0
StringReplace, MAC, MAC, %A_Space%,, All
GuiControl,, Vendor, Searching...
WR := ComObjCreate("InternetExplorer.Application")
WR.Visible := False
WR.Navigate("www.coffer.com/mac_find/?string=" . MAC)
While WR.ReadyState < 4
{
	Sleep, 100
	If Tout = 50 ;Times out after 5 seconds (100 x 50 = 5000ms)
	{
		GuiControl,, Vendor, Timed out.
		Return
	}
	Tout++
}
Elements := WR.document.getElementsByClassName("table2")
Ven := Elements[Elements.length-1].innerText
GuiControl,, Vendor, % Ven
WR.quit()
Return

GuiClose:
ExitApp

User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: MAC Address Vendor ID

Post by TLM » 04 Feb 2015, 16:03

nice work Bkid :)
you don't even have to use an internet explorer client.
just use HttpRequest and HTMLfile objects together

Code: Select all

MAC = 00-80-C7

ReqObj := ComObjCreate( "WinHttp.WinHttpRequest.5.1" )
ReqObj.Open( "GET", "http://www.coffer.com/mac_find/?string=" . MAC )
ReqObj.Send()

DocObj := ComObjCreate( "HTMLfile" )
DocObj.write( ReqObj.ResponseText )

msgbox % DocObj.getElementsByTagName( "table" )[ 0 ].InnerText
Should speed up the process as there's no waiting for a page to load ;) hth

Bkid
Posts: 31
Joined: 13 Jun 2014, 12:19

Re: MAC Address Vendor ID

Post by Bkid » 04 Feb 2015, 16:09

Ya know we said the same thing in IRC, and I was eventually going to change it..but then I never did. :P

User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: MAC Address Vendor ID

Post by TLM » 04 Feb 2015, 16:13

lol :) one more addition won't hurt then...

Code: Select all

MAC = 00-80-C7

ReqObj := ComObjCreate( "WinHttp.WinHttpRequest.5.1" )
ReqObj.Open( "GET", "http://www.coffer.com/mac_find/?string=" . MAC )
ReqObj.Send()

DocObj := ComObjCreate( "HTMLfile" )
DocObj.write( ReqObj.ResponseText )

Data := DocObj.getElementsByTagName( "td" )
Result := { Prefix: Data[ 0 ].innerText, Vendor: Data[ 1 ].innerText }

msgbox % "Prefix: " Result.Prefix "`nVendor: " Result.Vendor

Bkid
Posts: 31
Joined: 13 Jun 2014, 12:19

Re: MAC Address Vendor ID

Post by Bkid » 05 Feb 2015, 12:25

Combined ours :P

Code: Select all

#SingleInstance, Force
#NoEnv

Gui, Add, Text, x0 w215 Center, Enter the first six characters or full MAC.
Gui, Add, Text, x10 y+10 w68 h12, Modem MAC:
Gui, Add, Edit, x+2 yp-3 w125 gCheckMACLen vMAC Limit17
Gui, Add, Text, x10 y+7 w68 h12, Vendor:
Gui, Add, Edit, x+2 yp-3 w125 ReadOnly vVendor
Gui, Add, Button, x10 y+7 w195 vSearchBtn gSearch, Search
Gui, Show, w215, MAC Vendor ID
GuiControl, Disable, SearchBtn
Return

CheckMACLen:
Gui, Submit, NoHide
StringReplace, MAC, MAC, %A_Space%,, All
Len := (StrLen(MAC))
If MAC
	GuiControl, Enable, SearchBtn
Else
	GuiControl, Disable, SearchBtn
If Len in 6,8,12,17
	GuiControl, Enable, SearchBtn
Else
	GuiControl, Disable, SearchBtn
Return

Search:
Gui, Submit, NoHide
Tout = 0
StringReplace, MAC, MAC, %A_Space%,, All
GuiControl,, Vendor, Searching...

ReqObj := ComObjCreate( "WinHttp.WinHttpRequest.5.1" )
ReqObj.Open( "GET", "http://www.coffer.com/mac_find/?string=" . MAC )
ReqObj.Send()

DocObj := ComObjCreate( "HTMLfile" )
DocObj.write( ReqObj.ResponseText )

GuiControl,, Vendor, % DocObj.getElementsByTagName("td")[1].innerText
Return

GuiClose:
ExitApp

User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: MAC Address Vendor ID

Post by TLM » 05 Feb 2015, 14:15

cool :D
the com objects don't need to be created each time by doing something like

Code: Select all

#SingleInstance, Force
#NoEnv

ReqObj := ComObjCreate( "WinHttp.WinHttpRequest.5.1" )
DocObj := ComObjCreate( "HTMLfile" )

Gui, Add, Text, x0 w215 Center, Enter the first six characters or full MAC.
Gui, Add, Text, x10 y+10 w68 h12, Modem MAC:
Gui, Add, Edit, x+2 yp-3 w125 gCheckMACLen vMAC Limit17
Gui, Add, Text, x10 y+7 w68 h12, Vendor:
Gui, Add, Edit, x+2 yp-3 w125 ReadOnly vVendor
Gui, Add, Button, x10 y+7 w195 vSearchBtn gSearch, Search
Gui, Show, w215, MAC Vendor ID
GuiControl, Disable, SearchBtn

Return

CheckMACLen:
Gui, Submit, NoHide
StringReplace, MAC, MAC, %A_Space%,, All
Len := (StrLen(MAC))
If MAC
    GuiControl, Enable, SearchBtn
Else
    GuiControl, Disable, SearchBtn
If Len in 6,8,12,17
    GuiControl, Enable, SearchBtn
Else
    GuiControl, Disable, SearchBtn
Return

Search:
Gui, Submit, NoHide
Tout = 0
StringReplace, MAC, MAC, %A_Space%,, All
GuiControl,, Vendor, Searching...

ReqObj.Open( "GET", "http://www.coffer.com/mac_find/?string=" . MAC )
ReqObj.Send()

DocObj.write( ReqObj.ResponseText )

GuiControl,, Vendor, % DocObj.getElementsByTagName("td")[1].innerText
DocObj.close()
Return

GuiClose:
ExitApp

Bkid
Posts: 31
Joined: 13 Jun 2014, 12:19

Re: MAC Address Vendor ID

Post by Bkid » 05 Feb 2015, 14:18

Actually yeah that's true. We saved 0.0004% processor power! :D

User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: MAC Address Vendor ID

Post by TLM » 05 Feb 2015, 14:27

Bkid wrote:Actually yeah that's true. We saved 0.0004% processor power! :D
lol

I was wondering if this would work

Code: Select all

for i, obj in [ "WinHttp.WinHttpRequest.5.1" , "HTMLfile" ]
    ( i=1 ? ReqObj : DocObj ) := ComObjCreate( obj )
.. it does lmao

Post Reply

Return to “Scripts and Functions (v1)”