Code:
' Copyright Marius Milner 2004.
' Use with NetStumbler. Edit. Enjoy.
Dim ActiveMap
Dim LastLocation
Dim MapPointApp
Dim HistoryPushpins
Dim MotionPushpins
Dim WLANPushpins
Dim Vehicle
Dim Initialized
Dim BSSID_Dictionary, Spoken_BSSIDs, New_SSIDs
Dim IsScanning
Dim HadGPSData
Dim LastLatitude, LastLongitude, LastAltitude
Dim DropCrumbs, TrackVehicle, UseSpeech, UseAudio
Dim LastHighlighted
Dim SNR
Dim WNetSSID
Dim WNetMac
Dim WNetLast
Dim WnetCap
Dim WnetMaxSNR
DropCrumbs = True ' True to put black dots everywhere we go, False otherwise
TrackVehicle = True ' True to follow your location while scanning
UseSpeech = True ' Speak names of networks in view
UseAudio = True ' Traditional script audio
const CrumbGap = 2
AddItemContextMenu "HighlightOnMap", "Highlight on map"
Set LastHighlighted = Nothing
Set WLANPushpins = Nothing
Dim TTS
If UseSpeech Then
Set TTS = CreateObject("Sapi.SpVoice")
If TTS Is Nothing Then
UseSpeech = False
End If
End If
If UseSpeech Then
TTS.Speak "Good Day two u Duesh bag!"
Set Spoken_BSSIDs = CreateObject("Scripting.Dictionary")
Set New_SSIDs = CreateObject("Scripting.Dictionary")
End If
' Initialize
Sub Initialize
On Error Resume Next
HadGPSData = False
SNR = 0
set BSSID_Dictionary = CreateObject("Scripting.Dictionary")
' Try to get a handle to an existing instance of MapPoint
set MapPointApp = GetObject(, "MapPoint.Application")
' No instance found, create one.
if Err <> 0 then
Err.Clear
set MapPointApp = CreateObject("MapPoint.Application")
MapPointApp.Visible = true
MapPointApp.UserControl = false
MapPointApp.Activate
end if
set ActiveMap = MapPointApp.ActiveMap
dim StartLoc
Set StartLoc = ActiveMap.FindResults("Broomfield, CO")(1) ' Middle of, uh, somewhere
If DropCrumbs Then
Set HistoryPushpins = ActiveMap.Datasets.AddPushpinSet("Location History")
if Err <> 0 then
Err.Clear
Set HistoryPushpins = ActiveMap.Datasets("Location History")
end if
End If
Set WLANPushpins = ActiveMap.Datasets.AddPushpinSet("Wireless LAN data")
if Err <> 0 then
Err.Clear
Set WLANPushpins = ActiveMap.Datasets("Wireless LAN data")
end if
If TrackVehicle Then
Set MotionPushpins = ActiveMap.Datasets.AddPushpinSet("Last Location")
if Err <> 0 then
Err.Clear
Set MotionPushpins = ActiveMap.Datasets("Last Location")
end if
Set Vehicle = MotionPushpins("Last Location")
if Err <> 0 then
Err.Clear
Set Vehicle = FindOrAddPushpin(StartLoc, "Last Location", False)
end if
Vehicle.Symbol = 176 ' Pirate icon :-)
Vehicle.Highlight = True
Vehicle.MoveTo(MotionPushpins)
End If
Initialized = True
End Sub
Sub HighlightOnMap(bssid, ssid)
If Not LastHighlighted Is Nothing Then
LastHighlighted.Highlight = False
LastHighlighted.BalloonState = 0
End If
If BSSID_Dictionary.Exists(bssid) Then
Set LastHighlighted = BSSID_Dictionary.Item(bssid)
LastHighlighted.Highlight = True
LastHighlighted.BalloonState = 2
LastHighlighted.GoTo
End If
End Sub
Function FindOrAddPushpin(Loc, Title, InDict)
On Error Resume Next
Dim pp
Set pp = Nothing
Set pp = ActiveMap.AddPushpin(loc, Title)
' If pp Is Nothing Then Set pp = ActiveMap.FindPushpin(Title)
Set BSSID_Dictionary.Item(Title) = pp
Set FindOrAddPushpin = pp
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub OnGPSPosition (Lat, Lon, Alt)
' Lat : double : Latitude, degrees east
' Lon : double : Longitude, degrees north
' Alt : double : Altitude above sea level, meters
if not Initialized then
Initialize
end if
if HadGPSData then
' If we haven't moved, do nothing.
if LastLatitude = Lat And LastLongitude = Lon And LastAltitude = Alt Then Exit Sub
end if
LastLatitude = Lat
LastLongitude = Lon
LastAltitude = Alt
set LastLocation = ActiveMap.GetLocation(Lat, Lon, Alt)
If DropCrumbs Then
Dim Crumb
Set Crumb = FindOrAddPushpin(LastLocation, WNetMac, False)
IF SNR >= 30 Then
Crumb.Symbol = 22
ElseIf SNR >= 21 Then
Crumb.Symbol = 22
ElseIf SNR >= 15 Then
Crumb.Symbol = 18
ElseIf SNR < 15 Then
Crumb.Symbol = 17
End if
SNR=0
Dim Flags
Flags = ""
if (WnetCap Mod 2) = 1 then Flags = Flags & "ESS "
if ((WnetCap / 2) Mod 2) = 1 then Flags = Flags & "IBSS "
if ((WnetCap / 16) Mod 2) = 1 then Flags = Flags & "WEP "
crumb.Note = "SSID: " & WNetSSID & vbCrLf & _
"BSSID: " & WNetMac & vbCrLf & _
"CapFlags: " & Flags & " (" & Hex(Wnetcap) & ")" & vbCrLf & _
"SNR: " & SNR
Crumb.MoveTo(HistoryPushpins)
End If
If TrackVehicle Then
' Move the visual indicator to the new location.
Set Vehicle.Location = LastLocation
MotionPushpins.ZoomTo
End If
HadGPSData = True
End Sub
' Called when user requests that scanning start, or when scanning is started automatically.
Sub OnEnableScan
If Not HadGPSData Then Exit Sub ' Discard while no GPS
if not Initialized then
Initialize
end if
IsScanning = True
End Sub
' Called when user requests that scanning stop.
Sub OnDisableScan
If WLANPushpins Is Nothing Then
' Blah
Else
WLANPushpins.ZoomTo
End If
IsScanning = False
End Sub
Sub OnScanResult(SSID, BSSID, CapFlags, Signal, Noise, LastSeen)
' SSID : String : SSID (Network name)
' BSSID : String : BSSID (MAC address)
' CapFlags : Integer : 802.11 capability flags
' Signal : Integer : signal level (dBm)
' Noise : Integer : noise level(dBm)
' LastSeen : Time
If SSID = "Wireless Net" Then
SNR = Signal - Noise
IF SNR > WnetMaxSNR Then WnetMaxSNR = SNR
WNetSSID = SSID
WNetMac = BSSID
WNetLast = LastSeen
WnetCap = CapFlags
If Not Spoken_BSSIDs.Exists(BSSID) Then
New_SSIDs.Item(SSID) = 1
Spoken_BSSIDs.Item(BSSID) = LastSeen
End If
End If
End Sub
' Called to indicate that NetStumbler has changed its location information
' for a BSSID. The new location may not necessarily be the place where you
' are right now.
' History: New in 0.4.
Sub OnPositionChange (SSID, BSSID, CapFlags, MaxSNR, Lat, Lon, Alt, FixType)
' SSID : String : SSID (Network name)
' BSSID : String : BSSID (MAC address)
' CapFlags : Integer : 802.11 capability flags
' MaxSNR: Integer : highest seen signal-to-noise ratio (dB) that had a position fix associated with it
' Lat : Double : Newly calculated latitude, degrees
' Lon : Double : Newly calculated longitude, degrees
' Alt : Double : Newly calculated altitude (currently not calculated)
' FixType : Integer : Reserved for future use.
if not Initialized then
' To get here, start with no script, start scan, then enable script
Initialize
IsScanning = True
end if
If SSID = "Wireless Net" Then
WnetMaxSNR = MaxSNR
End If
Set newLocation = Nothing
End Sub
' Called when a scan cycle has completed (typically right before a new one starts).
Sub OnScanComplete(FoundNew, SeenBefore, LostContact, BestSNR)
' FoundNew : Integer : Count of new BSSIDs
' SeenBefore : Integer : Count of not-new BSSIDs
' LostContact : Integer : Count of BSSIDs missed since last scan
' BestSNR : Integer : SNR of strongest signal (dBm)
If UseSpeech Then
If (New_SSIDs.Count > 0) Then
Dim n, a
n = New_SSIDs.Count
a = New_SSIDs.Keys
For i = 0 to n-1
TTS.Speak " New " & a(i) & " AP Found!", SVSFlagsAsync
Next
New_SSIDs.RemoveAll
ElseIf UseAudio Then
If FoundNew>0 Then
'PlaySound "ns-aos-new.WAV"
' ElseIf LostContact>0 Then
' PlaySound "ns-los.WAV"
ElseIf SeenBefore>0 Then
' Still seeing some
If WnetMaxSNR >= 40 Then
TTS.Speak "Kick Ass!", SVSFlagsAsync
'PlaySound "ns-signal-4.WAV"
ElseIf WnetMaxSNR >= 30 Then
TTS.Speak "Good!", SVSFlagsAsync
'PlaySound "ns-signal-3.WAV"
ElseIf WnetMaxSNR >= 21 Then
TTS.Speak "Marginal!", SVSFlagsAsync
'PlaySound "ns-signal-2.WAV"
ElseIf WnetMaxSNR >= 15 Then
TTS.Speak "Signal is Crap!", SVSFlagsAsync
'PlaySound "ns-signal-1.WAV"
Else
TTS.Speak "No Signal!", SVSFlagsAsync
'PlaySound "ns-signal-0.WAV"
End If
End if
Else
' Nothing seen
' PlaySound "ns-tick.WAV"
End If
WnetMaxSNR = 0
End If
End Sub
I modified the above code (more liked hacked it all to hell) and It seems to produce the results I'm looking for. What do you guys think?
edit: I figured I would add to this thread because I was using a version of the MasterScript. Thanks for the help though Ted.