|
-
Jun 21st, 2012, 07:32 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] identity your own router
hi im tring to make a download limiter for my home computers but ive run into another problem ..i need my program to know if its my own home router or not.
do i use the 192.168.etc then my password from the program?
thanks
-
Jun 21st, 2012, 08:10 PM
#2
Thread Starter
Fanatic Member
Re: identity your own router
does anyone know the best way to get the router name once im hooked up to the router?
-
Jun 21st, 2012, 08:13 PM
#3
Re: identity your own router
I have never tried but I would imagion it may be different depending on what kind of router it is.
-
Jun 21st, 2012, 08:17 PM
#4
Thread Starter
Fanatic Member
Re: identity your own router
i can go into the router using internet control but i dont know any other way
-
Jun 21st, 2012, 09:13 PM
#5
Re: identity your own router
 Originally Posted by flyhigh
hi im tring to make a download limiter for my home computers but ive run into another problem ..i need my program to know if its my own home router or not.
do i use the 192.168.etc then my password from the program?
thanks
Yes. That will get you to your control panel
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 21st, 2012, 09:14 PM
#6
Re: identity your own router
 Originally Posted by flyhigh
does anyone know the best way to get the router name once im hooked up to the router?
It should be in your control panel or on your router
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 21st, 2012, 09:18 PM
#7
Re: identity your own router
 Originally Posted by flyhigh
i can go into the router using internet control but i dont know any other way
That's about it. There is a way to get to your router interface via code (depending on router) but then you need to know how to program your router.
I think it's probably easier to use the online control panel then using WebBrowser modify fields on the document page using code and also using code click on the buttons.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 22nd, 2012, 07:51 AM
#8
Thread Starter
Fanatic Member
Re: identity your own router
i dont understand ((online control panel then using WebBrowser))the webbrowser is (micrsoft internet control),but i dont know about online control panel .
-
Jun 22nd, 2012, 07:58 AM
#9
Re: identity your own router
When you access your router via a browser it should prompt you for an id and password then it should give you a page with configuration options. This is what is being refered to as the online control panel. It's just the routers config pages.
-
Jun 22nd, 2012, 08:02 AM
#10
Thread Starter
Fanatic Member
Re: identity your own router
i can get to the id and password but my program stops ,
its soposed to inter password hit the tab key but it stops
-
Jun 22nd, 2012, 10:20 PM
#11
Thread Starter
Fanatic Member
Re: identity your own router
why does my program not write to the routers config page?
-
Jun 22nd, 2012, 11:54 PM
#12
Re: identity your own router
Hard to say, not seeing how you are doing it. I don't know if you are using a WebBrowser control and trying to fill in the fields or if you are trying to do it with code after getting to your router via code.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 23rd, 2012, 12:57 AM
#13
Re: identity your own router
if you are trying to get in your router you will have to use the document
and for us to help you we would need the same router or at least the name of the username and password textbox name on the internet explorer/webbrowser control
and if you could show us how you are doing it maybe we could point you in the right direction!
-
Jun 23rd, 2012, 01:15 AM
#14
Frenzied Member
Re: identity your own router
hi im tring to make a download limiter for my home computers but ive run into another problem ..i need my program to know if its my own home router or not.
do i use the 192.168.etc then my password from the program?
thanks
Just type ipconfig/all .at dos prompt .there you will get DHCP Server .those ip you need to use at web browser .to open the control panel page .
-
Jun 23rd, 2012, 02:01 AM
#15
Re: identity your own router
Ipconfig will not help in this case
There is not much anyone can tell you about what you are doing wrong unless you show us what you are doing.
It would also help to know what router you are using.
-
Jun 23rd, 2012, 04:42 AM
#16
Re: identity your own router
does anyone know the best way to get the router name once im hooked up to the router?
why would you need to know the name?
it is quite possible to do what you want, but not easy at all
most router config pages use nested framesets (pages within pages), you need to wait for each page to load, before trying to access its elements
as mentioned above, all routers are different, event same models, but with different firmware, so no one else can help with specific solutions, it is basically up to you to do trial and error, with some suggestions form forum
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 23rd, 2012, 08:04 AM
#17
Thread Starter
Fanatic Member
Re: identity your own router
hi its a cisco e2500 ,neather of theses will work.
the progarm should check for my router if it is not my router then it does nothing.
im looking up nested framesets.
thanks for yalls help
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As _
Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal _
dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_ALT = &H12
Private Const VK_TAB = &H9
Private Sub Command1_Click()
WebBrowser1.Navigate "http://192.168.1.1"
' Press Tab.
keybd_event VK_TAB, 1, 0, 0
End Sub
Private Sub Command2_Click()
SendKeys "This is a test."
End Sub
-
Jun 23rd, 2012, 08:40 AM
#18
Thread Starter
Fanatic Member
Re: identity your own router
ok im going about it in the wrong way i should be using html threw vb6 i guess it possiable
-
Jun 23rd, 2012, 09:46 AM
#19
Re: identity your own router
Code:
Dim MyURL
Private Sub Command1_Click()
MyURL = "http://192.168.1.1"
WebBrowser1.Navigate MyURL
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
'
'
If InStr(MyURL, URL) > 0 Then
'
' Here your 1st page of your control panel has fully loaded. Now you can start to either fill in the
' user name and password fields and click on the button either through code or manually. If you do it
' through code you will need to examine the source of the page and find the names of the fields
' and the name of the button you need to click on. Once you have that then you will do something
' like below. Note: the names in quote marks are just to illustrate what your first step is and the names
' are not the real names - you will need to find those from the source of the page.
' Once you have this then you can post back if (and I'm sure you will) have problems
' on specific situations
'
WebBrowser1.Document.All.Item("username").Value = Username
WebBrowser1.Document.All.Item("password").Value = Password
WebBrowser1.Document.All.Item("btnSubmit").Click
'
'
End If
End Sub
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 23rd, 2012, 01:45 PM
#20
Thread Starter
Fanatic Member
Re: identity your own router
hi this >>>If InStr(MyURL, URL) > 0 Then<<<is staying as zero
-
Jun 23rd, 2012, 02:30 PM
#21
Re: identity your own router
Sorry about that. Switch the two around
If InStr(URL, MyURL) > 0 Then
Last edited by jmsrickland; Jun 23rd, 2012 at 02:37 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 23rd, 2012, 02:58 PM
#22
Thread Starter
Fanatic Member
Re: identity your own router
im getting error 91 it says im sopused to >>set the object as something,do i set pdisp as something
-
Jun 23rd, 2012, 03:32 PM
#23
Re: identity your own router
 Originally Posted by flyhigh
im getting error 91 it says im sopused to >>set the object as something,do i set pdisp as something
It should work just as I posted it. That is the same code, minus the guts since that would not apply to you, I use to get to my router service panel. Just don't use the code I put it there as that is only for illustration reasons and will not be the values in your case which I pointed out in the sample code post.
WebBrowser1.Document.All.Item("username").Value = Username
You need to put the real name of the field, not "username" as shown. You need to look at the source of the web page you get and find the names of the fields you need to use and the name of the button so you can click it.
To get the source of the page add something like this in the _DocumentComplete event:
Code:
'
Dim s As String
s = WebBrowser1.Document.documentElement.innerHTML 'get html code
Open App.Path & "\HTML_SOURCE.txt" For Output As #1
Print #1, s
Close #1
'
'
Now you have to look at that source and try to find where the text boxes are that accept username and password and get their names. Also look in the source for where the button is and get it's name.
Last edited by jmsrickland; Jun 23rd, 2012 at 03:42 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 23rd, 2012, 04:53 PM
#24
Thread Starter
Fanatic Member
Re: identity your own router
when i run it i get a popup window wanting user name and pw
,,,but html_source.txt file only get the wrong window.
-
Jun 23rd, 2012, 06:23 PM
#25
Re: identity your own router
Ummm..... when I run my app using that approach (like the code sample) I get the main login window as the main browser window but you sound like what you are getting is in addition or only (not sure if only one or both) a seperate popup window for your username and password. Since I do not get a seperate popup window I can't debug the situation but I think you can trap the popup in a seperate event.
Here's what happens when you navigate to a website. You first navigate to the desired website (like http://www.vbforums.com but that is not the only reason your _DocumentComplete event is fired. It is fired whenever any document arrives, not just the one you navigated to. In your _DocumentComplete event you need to trap all incoming pages, not just the one you explicitly navigated to but others as well. Some you can ignore and others you may need that page, like your popup for example. Only trial and error can give you the proper way to handle this. It is not a cut and dry situation at all. What I do is set a break point in the _DocumentComplete event at the If statement. Then I examine the URL at each hit noting what it says. If it is something I don't need I write code to ignore it; if it is a page I need I write down the info I see in the URL and make another IF to catch that one, etc, etc.
Here's somewhat small illustration of what I mean.
Code:
Dim MyURL
Private Sub Command1_Click()
MyURL = "http://192.168.1.1"
WebBrowser1.Navigate MyURL
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
' 1) Put a break point on the If statement
' 2) Look at the URL. If this URL is not what you need then just exit sub. Now
' 3) wait for the next entry if there is one. If this is the URL you need that has
' 4) the page with the username and password fields then write down it's address
' 5) and put it in an If statement so you will get it the next time.
' 6) You will need to do this until you get the page that contains the info you need
'
'
'
If InStr(MyURL, URL) > 0 Then
If URL = "address you wrote down from steps 4 and 5" Then
Dim s As String
s = WebBrowser1.Document.documentElement.innerHTML 'get html code
Open App.Path & "\HTML_SOURCE.txt" For Output As #1
Print #1, s
Close #1
'NotReadyYet--->WebBrowser1.Document.All.Item("name_of_field").Value = Username
'NotReadyYet--->WebBrowser1.Document.All.Item("name_of_field").Value = Password
'NotReadyYet--->WebBrowser1.Document.All.Item("name_of_button").Click
End If
End If
End Sub
Try this first. If you cannot the correct page then we have to try another way but first try it this way.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 23rd, 2012, 06:51 PM
#26
Re: identity your own router
Here's another idea simplier than above.
Code:
Dim MyURL
Private Sub Command1_Click()
MyURL = "http://192.168.1.1"
WebBrowser1.Navigate MyURL
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim s As String
Static counter As Integer
counter = counter +1
s = WebBrowser1.Document.documentElement.innerHTML 'get html code
Open App.Path & "\HTML_SOURCE(" & counter & ").txt" For Output As #1
Print #1, s
Close #1
End Sub
Now look and see how many files you have like
HTML_SOURCE(1).txt
HTML_SOURCE(2).txt
etc
One of them could be the one you need. If not then the popup is not triggering the _DocumentComplete event then we need to go into the WebBrowser1_NewWindow2 event which might trap the popup window.
BTW: How do you know that the text file you looked is the wrong window? Did you examine it for the code for the text fields and button?
Last edited by jmsrickland; Jun 23rd, 2012 at 06:54 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 23rd, 2012, 08:11 PM
#27
Re: identity your own router
try this see if it helps
start vb6
-Standard EXE
-In Form1 code Add:
Code:
Private IE As Object
Private TempLabel As Label
Private Sub Form_Load()
Dim ObjName As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = False
.Navigate "192.168.1.1" 'Your router ip IF this one is wrong
End With
Do While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE 'Loop until page is loaded which is INVISIBLE
DoEvents
Loop
Set TempLabel = Me.Controls.Add("VB.Label", "TempLabel")
With TempLabel
.Visible = True
.Move 0, 0, Me.Width, Me.Height
End With
For Each ObjName In IE.Document.All
If ObjName.GetAttribute("Name") <> 0 Then
TempLabel.Caption = TempLabel.Caption & ObjName.GetAttribute("name") & vbCrLf
End If
Next
Clipboard.Clear
Clipboard.SetText TempLabel.Caption
IE.Quit
Set IE = Nothing
Unload Me
End Sub
-Start (Run Project)
-Come back to this thread
-In the reply textbox paste what is in your ClipBoard (Right mouse click goto Paste from the menu that appears)
after you do that we will assist you with your code
Last edited by Max187Boucher; Jun 23rd, 2012 at 08:16 PM.
Reason: Private WithEvents TempLabel As Label ... to ... Private TempLabel As Label
-
Jun 23rd, 2012, 09:27 PM
#28
Re: identity your own router
READYSTATE_COMPLETE has no value
Your code needs:
Private Const READYSTATE_COMPLETE = 4
This is what I get: Are some of these to be the names of the fields he needs?
form_contents
active_page
active_page_str
page_title
mimic_button_field
button_value
strip_page_top
logo
vz_logo
actiontec_lt_top_corner
empty
actiontec_rt_top_corner
empty
empty
user_name_defval
user_name
passwordmask_183249899
passwd1
md5_pass
auth_key
empty
empty
empty
actiontec_lt_btm_corner
empty
actiontec_rt_btm_corner
Last edited by jmsrickland; Jun 23rd, 2012 at 09:40 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 23rd, 2012, 09:35 PM
#29
Re: identity your own router
well then you add that to the code 
vb Code:
Option Explicit
Private Const READYSTATE_COMPLETE As Integer = 4
Private IE As Object
Private TempLabel As Label
Private Sub Form_Load()
Dim ObjName As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = False
.Navigate "192.168.1.1" 'Your router ip IF this one is wrong
End With
Do While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE 'Loop until page is loaded which is INVISIBLE
DoEvents
Loop
Set TempLabel = Me.Controls.Add("VB.Label", "TempLabel")
With TempLabel
.Visible = True
.Move 0, 0, Me.Width, Me.Height
End With
For Each ObjName In IE.Document.All
If ObjName.GetAttribute("Name") <> 0 Then
TempLabel.Caption = TempLabel.Caption & ObjName.GetAttribute("name") & vbCrLf
End If
Next
Clipboard.Clear
Clipboard.SetText TempLabel.Caption
IE.Quit
Set IE = Nothing
Unload Me
End Sub-Start (Run Project)
-
Jun 23rd, 2012, 09:40 PM
#30
Re: identity your own router
user_name = username?
passwd1 = password?
-
Jun 23rd, 2012, 09:43 PM
#31
Re: identity your own router
haha i like how you edit your post jmsrickland!
could also get Id instead of Name
Code:
Private Const READYSTATE_COMPLETE As Integer = 4
Private IE As Object
Private TempLabel As Label
Private Sub Form_Load()
Dim ObjName As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = False
.Navigate "192.168.1.1" 'Your router ip IF this one is wrong
End With
Do While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE 'Loop until page is loaded which is INVISIBLE
DoEvents
Loop
Set TempLabel = Me.Controls.Add("VB.Label", "TempLabel")
With TempLabel
.Visible = True
.Move 0, 0, Me.Width, Me.Height
End With
For Each ObjName In IE.Document.All
If ObjName.GetAttribute("id") <> 0 Then
TempLabel.Caption = TempLabel.Caption & ObjName.GetAttribute("id") & vbCrLf
End If
Next
Clipboard.Clear
Clipboard.SetText TempLabel.Caption
IE.Quit
Set IE = Nothing
Unload Me
End Sub
Last edited by Max187Boucher; Jun 23rd, 2012 at 09:54 PM.
Reason: .Navigate "192.168.0.1" .... to .... .Navigate "192.168.1.1" as OP is
-
Jun 23rd, 2012, 10:30 PM
#32
Re: identity your own router
Why do you use a label? I can't copy from a label. I had to change to a text box
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 23rd, 2012, 10:38 PM
#33
Re: identity your own router
to identify if its your router you can try this
Code:
Option Explicit
Private Const READYSTATE_COMPLETE As Integer = 4
Private IE As Object
Private TempLabel As Label
Private Sub Form_Load()
Dim ObjName As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = False
.Navigate "192.168.1.1" 'Your router ip IF this one is wrong
End With
Do While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE 'Loop until page is loaded which is INVISIBLE
DoEvents
Loop
Set TempLabel = Me.Controls.Add("VB.Label", "TempLabel")
With TempLabel
.Visible = True
.Move 0, 0, Me.Width, Me.Height
End With
For Each ObjName In IE.Document.All
TempLabel.Caption = TempLabel.Caption & ObjName.innertext & vbCrLf
Next
If InStr(1, UCase(TempLabel.Caption), UCase("Linksys E2500")) <> 0 Then
MsgBox "Found Linksys E2500"
ElseIf InStr(1, UCase(TempLabel.Caption), UCase("Linksys")) <> 0 Then
MsgBox "Found Linksys"
ElseIf InStr(1, UCase(TempLabel.Caption), UCase("Cisco")) <> 0 Then
MsgBox "Found Cisco"
Else
MsgBox "Did not find any match!"
End If
Clipboard.Clear
Clipboard.SetText TempLabel.Caption
IE.Quit
Set IE = Nothing
Unload Me
End Sub
-
Jun 23rd, 2012, 10:40 PM
#34
Re: identity your own router
i used label because i was thinking of doing it differently... yes you can use textbox if you would like... i was going to use WithEvents and textbox then when text change copy to clipboard but i forgot the textbox will NOT be MULTILINE so i had to change to label to get it properly
-
Jun 24th, 2012, 05:18 AM
#35
Thread Starter
Fanatic Member
Re: identity your own router
morning
its a popup window ,but when i try sendkeys it goes into a loop,but never prints to screen.
ive been looking at WebBrowser1_NewWindow2 event but cant figure out how to use it
-
Jun 24th, 2012, 07:02 AM
#36
Thread Starter
Fanatic Member
Re: identity your own router
ok the only way i could get it to work is shell to another program it types in using sendkeys and return,
is there another way that works better?
and thanks for all your help
-
Jun 24th, 2012, 09:49 AM
#37
Re: identity your own router
 Originally Posted by flyhigh
morning
its a popup window ,but when i try sendkeys it goes into a loop,but never prints to screen.
ive been looking at WebBrowser1_NewWindow2 event but cant figure out how to use it
Did you put a break point in the _NewWindow2 event to see if it is fired when the popup window occurs? If it does then we can continue on
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 24th, 2012, 10:19 AM
#38
Thread Starter
Fanatic Member
Re: identity your own router
Code:
Dim MyURL
Private Sub Command1_Click()
MyURL = "http://192.168.1.1"
WebBrowser1.Navigate MyURL
End Sub
Private Sub wWebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim s As String
Static counter As Integer
counter = counter + 1
s = WebBrowser1.Document.documentElement.innerHTML 'get html code
Open App.Path & "\HTML_SOURCE(" & counter & ").txt" For Output As #1
Print #1, s
Close #1
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)<<<<<i put break on this line nothing happens
Cancel = bNoNewWindow
End Sub
-
Jun 24th, 2012, 10:37 AM
#39
Thread Starter
Fanatic Member
Re: identity your own router
-
Jun 24th, 2012, 11:42 AM
#40
Re: identity your own router
Have you tried
http://username: [email protected]/
Sorry no space before password but if i write : p it does
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|