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
Printable View
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
does anyone know the best way to get the router name once im hooked up to the router?
I have never tried but I would imagion it may be different depending on what kind of router it is.
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.
i dont understand ((online control panel then using WebBrowser))the webbrowser is (micrsoft internet control),but i dont know about online control panel .
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.
i can get to the id and password but my program stops ,
its soposed to inter password hit the tab key but it stops
why does my program not write to the routers config page?
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.
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!
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 .:DQuote:
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
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.
why would you need to know the name?Quote:
does anyone know the best way to get the router name once im hooked up to the router?
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
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
ok im going about it in the wrong way i should be using html threw vb6 i guess it possiable
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
hi this >>>If InStr(MyURL, URL) > 0 Then<<<is staying as zero
Sorry about that. Switch the two around
If InStr(URL, MyURL) > 0 Then
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:
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.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
'
'
when i run it i get a popup window wanting user name and pw
,,,but html_source.txt file only get the wrong window.
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.
Try this first. If you cannot the correct page then we have to try another way but first try it this way.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
Here's another idea simplier than above.
Now look and see how many files you have likeCode: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
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?
try this see if it helps
start vb6
-Standard EXE
-In Form1 code Add:
-Start (Run Project)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
-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
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
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)
user_name = username?
passwd1 = password?
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
Why do you use a label? I can't copy from a label. I had to change to a text box
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
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
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
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
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
it did not happen
Have you tried
http://username: [email protected]/
Sorry no space before password but if i write : p it does :p