From: Norm on 13 Jun 2010 18:59 I am trying to automate the opening and signing in on a web page that requires a user name and a password. The code listed below works in Windows 7 64 bit, both in the IDE and compiled. In Windows 7 32 Bit it only works in IDE mode. When compiled the web page does not get the SendKeys. If I try to just send the page to where it goes after clicking on the signon button I get a message that I am already signed off. Is there a better way to do this? Code: Option Explicit Private WithEvents Explorer As InternetExplorer Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Form_Load() Dim i As Long Dim obj Set Explorer = New InternetExplorer Explorer.Visible = True Explorer.Navigate2 "https://www.wellsfargo.com/" End Sub Private Sub Explorer_DocumentComplete(ByVal pDisp As Object, URL As Variant) Dim obj Dim i As Long If pDisp Is Explorer Then On Error Resume Next If Explorer.LocationURL = "https://www.wellsfargo.com/" Then For Each obj In Explorer.Document.All() If obj.Type = "text" And obj.Name = "userid" Then obj.Value = "*********" If obj.Name = "password" Then obj.Value = "*********" If obj.Name = "destination" Then obj.Value = "AccountSummary" Next End If End If Me.Timer1.Interval = 1000 Me.Timer1.Enabled = True Explorer.Application.SetFocus End Sub Private Sub Form_Unload(Cancel As Integer) Set Explorer = Nothing Set Form1 = Nothing End Sub Private Sub Timer1_Timer() Dim i As Long Me.Timer1.Enabled = False Sleep 50 SendKeys "{Enter}" Do Until i = 200 DoEvents Sleep 10 i = i + 1 Loop Unload Me End Sub
From: Larry Serflaten on 13 Jun 2010 21:58 "Norm" <NormF4(a)Spoof.com> wrote > If I try to just send the page to where it goes after clicking on the > signon button I get a message that I am already signed off. > > Is there a better way to do this? > Private Sub Timer1_Timer() > Dim i As Long > > Me.Timer1.Enabled = False > Sleep 50 > SendKeys "{Enter}" Sending Enter may only work if the right object has focus. Instead of using SendKeys, why not simulate clicking on the button? (Use the Click method of the button object) LFS
From: Jason Keats on 13 Jun 2010 22:13 Larry Serflaten wrote: > "Norm"<NormF4(a)Spoof.com> wrote > >> If I try to just send the page to where it goes after clicking on the >> signon button I get a message that I am already signed off. >> >> Is there a better way to do this? > >> Private Sub Timer1_Timer() >> Dim i As Long >> >> Me.Timer1.Enabled = False >> Sleep 50 >> SendKeys "{Enter}" > > > Sending Enter may only work if the right object has focus. > Instead of using SendKeys, why not simulate clicking on the button? > (Use the Click method of the button object) > > LFS > > I believe SendKeys has known problems on modern versions of Windows. Try using the SendInput API. http://www.vbforums.com/showthread.php?t=412021
From: C. Kevin Provance on 13 Jun 2010 22:59 If you're already using the DOM to enter information, why not use the Click button method instead of that unreliable sendkeys? -- Customer Hatred Knows No Bounds at MSFT Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc Bawwk! Paulie want a dingleball, bawwk! "Norm" <NormF4(a)Spoof.com> wrote in message news:hv3nrq$uiq$1(a)news.eternal-september.org... :I am trying to automate the opening and signing in on a web page that : requires a user name and a password. The code listed below works in : Windows 7 64 bit, both in the IDE and compiled. In Windows 7 32 Bit it : only works in IDE mode. When compiled the web page does not get the : SendKeys. : : If I try to just send the page to where it goes after clicking on the : signon button I get a message that I am already signed off. : : Is there a better way to do this? : : Code: : Option Explicit : Private WithEvents Explorer As InternetExplorer : Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) : : Private Sub Form_Load() : Dim i As Long : Dim obj : : Set Explorer = New InternetExplorer : Explorer.Visible = True : Explorer.Navigate2 "https://www.wellsfargo.com/" : : End Sub : : Private Sub Explorer_DocumentComplete(ByVal pDisp As Object, URL As : Variant) : Dim obj : Dim i As Long : : If pDisp Is Explorer Then : On Error Resume Next : : If Explorer.LocationURL = "https://www.wellsfargo.com/" Then : For Each obj In Explorer.Document.All() : If obj.Type = "text" And obj.Name = "userid" Then : obj.Value = "*********" : If obj.Name = "password" Then obj.Value = "*********" : If obj.Name = "destination" Then obj.Value = : "AccountSummary" : Next : : End If : End If : : Me.Timer1.Interval = 1000 : Me.Timer1.Enabled = True : Explorer.Application.SetFocus : : End Sub : : Private Sub Form_Unload(Cancel As Integer) : Set Explorer = Nothing : Set Form1 = Nothing : End Sub : : Private Sub Timer1_Timer() : Dim i As Long : : Me.Timer1.Enabled = False : Sleep 50 : SendKeys "{Enter}" : : Do Until i = 200 : DoEvents : Sleep 10 : i = i + 1 : Loop : : Unload Me : End Sub : :
From: Norm on 14 Jun 2010 00:12 It happens that C. Kevin Provance formulated : > If you're already using the DOM to enter information, why not use the Click > button method instead of that unreliable sendkeys? > > -- > Customer Hatred Knows No Bounds at MSFT > Free usenet access at http://www.eternal-september.org > ClassicVB Users Regroup! comp.lang.basic.visual.misc > > Bawwk! Paulie want a dingleball, bawwk! > "Norm" <NormF4(a)Spoof.com> wrote in message > news:hv3nrq$uiq$1(a)news.eternal-september.org... >> I am trying to automate the opening and signing in on a web page that >> requires a user name and a password. The code listed below works in >> Windows 7 64 bit, both in the IDE and compiled. In Windows 7 32 Bit it >> only works in IDE mode. When compiled the web page does not get the >> SendKeys. >> >> If I try to just send the page to where it goes after clicking on the >> signon button I get a message that I am already signed off. >> >> Is there a better way to do this? >> >> Code: >> Option Explicit >> Private WithEvents Explorer As InternetExplorer >> Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) >> >> Private Sub Form_Load() >> Dim i As Long >> Dim obj >> >> Set Explorer = New InternetExplorer >> Explorer.Visible = True >> Explorer.Navigate2 "https://www.wellsfargo.com/" >> >> End Sub >> >> Private Sub Explorer_DocumentComplete(ByVal pDisp As Object, URL As >> Variant) >> Dim obj >> Dim i As Long >> >> If pDisp Is Explorer Then >> On Error Resume Next >> >> If Explorer.LocationURL = "https://www.wellsfargo.com/" Then >> For Each obj In Explorer.Document.All() >> If obj.Type = "text" And obj.Name = "userid" Then >> obj.Value = "*********" >> If obj.Name = "password" Then obj.Value = "*********" >> If obj.Name = "destination" Then obj.Value = >> "AccountSummary" >> Next >> >> End If >> End If >> >> Me.Timer1.Interval = 1000 >> Me.Timer1.Enabled = True >> Explorer.Application.SetFocus >> >> End Sub >> >> Private Sub Form_Unload(Cancel As Integer) >> Set Explorer = Nothing >> Set Form1 = Nothing >> End Sub >> >> Private Sub Timer1_Timer() >> Dim i As Long >> >> Me.Timer1.Enabled = False >> Sleep 50 >> SendKeys "{Enter}" >> >> Do Until i = 200 >> DoEvents >> Sleep 10 >> i = i + 1 >> Loop >> >> Unload Me >> End Sub >> >> I am having a problem understanding how this works. I assume to use the click button method I could use If obj.Name = "btnSignon" Then obj.click, but if I put that in the loop with entering the other information, the button does not get clicked, as the web page does not show the infomation until the Document_Complete has finished. It seems that once the Document_Complete has finished the Explorer object is released and I cannot use it in the Timer code. So I guess my question is where do I put the click button code to get it to work. Thanks, Norm
|
Next
|
Last
Pages: 1 2 Prev: Arranging windows of an external application Next: Handling DPI changes in my vb6 app |