>>lnTime=12000 && 12 seconds >>lox=.Null. >>Release lox >>Public lox >>oShell = Createobject("Shell.Application") >>&& A collection of the open windows that belong to the Shell >>oShellWindows = oShell.Windows >>For Each oIE In oShellWindows >> If "IEXPLORE.EXE" $ Justfname(Upper(oIE.FullName)) >> If 'CLIENT LOGIN'$Upper(oIE.LocationName) >> lox=oIE >> llAlredyup=.T. >> Exit >> Endif >> Endif >>Endfor >>oShellWindows = Null >>oShell = Null >>If !llAlredyup And Vartype(lox)#'O' >> lox=Createobject('internetexplorer.application') >> lox.Navigate('http://www.logixonline.co.uk/intcouriers2/newsite/client_login/index.asp') >> lox.Visible=.T. >> Wait 'Navigating!' Window Nowait >> If !NavComplete(lox,lnTime) >> ??Chr(7) >> Wait 'Timeout feil!' Window >> lox.Visible=.F. >> Release lox >> Return >> Endif >> Wait Clear >>Endif >>lox.Visible=.T. >>declare integer SetForegroundWindow in win32api Integer >>SetForegroundWindow(lox.HWND) >>SetForegroundWindow(_vfp.HWNd) >> >>If NavComplete(lox,lnTime) >> lox.Document.All.mainFrame.contentWindow.Document.Forms.login.username.Value='Username' >> lox.Document.All.mainFrame.contentWindow.Document.Forms.login.passwort.Value="password" >> lox.document.all.mainFrame.contentWindow.document.forms.login.submit.click() >> If !NavComplete(lox,lnTime) >> ??Chr(7) >> Wait 'timeout error!' Window >> lox.Visible=.F. >> Release lox >> Return >> Endif >>endif >> >>Function NavComplete >> Lpara toIE, tnTimeout >> lnTimeout=Iif( Type("tnTimeout")="N",tnTimeout ,60 ) >> lnTimeElapsed=0 >> lnStartSeconds=Seconds() >> Do While .T. >> If toIE.ReadyState=4 And !toIE.Busy >> Do While .T. >> If toIE.Document.ReadyState="complete" >> Return .T. >> Endif >> If (Seconds()-lnStartSeconds)>lnTimeout >> Return .F. >> Endif >> Enddo >> Endif >> If (Seconds()-lnStartSeconds)>lnTimeout >> Return .F. >> Endif >> Enddo>
Local oShell As [Shell.Application] Local lcClientID, llAlredyup, lnTime, oIE, oShellWindows m.lcClientID = [something] m.lnTime = 12000 && 12 seconds m.lox = .Null. Release m.lox Public lox m.oShell = Createobject([Shell.Application]) && A collection of the open windows that belong to the Shell oShellWindows = m.oShell.Windows m.llAlredyup = .F. For Each oIE In oShellWindows If [IEXPLORE.EXE] $ Justfname(Upper(oIE.FullName)) If [CLIENT LOGIN] $ Upper(oIE.LocationName) m.lox = oIE m.llAlredyup = .T. Exit Endif Endif Endfor oShellWindows = Null m.oShell = Null If !m.llAlredyup And Vartype(m.lox) # [O] m.lox = Createobject([internetexplorer.application]) m.lox.Navigate([http://www.logixonline.co.uk/intcouriers2/newsite/client_login/index.asp]) m.lox.Visible = .T. Wait [Navigating!] Window Nowait If !NavComplete(m.lox, m.lnTime) ??Chr(7) Wait [Timeout feil!] Window m.lox.Visible = .F. Release m.lox Return Endif Wait Clear Endif m.lox.Visible = .T. Declare Integer SetForegroundWindow In win32api Integer SetForegroundWindow(m.lox.HWnd) SetForegroundWindow(_vfp.HWnd) If NavComplete(m.lox, m.lnTime) m.lox.Document.Forms.loginform.Password.innertext = m.lcClientID m.lox.Document.Forms.loginform.submit.Click() If !NavComplete(m.lox, m.lnTime) ??Chr(7) Wait [timeout error!] Window m.lox.Visible = .F. Release m.lox Return Endif Endif Function NavComplete Lpara toIE, tnTimeout lnTimeout = Iif( Type([tnTimeout]) = [N], tnTimeout, 60 ) lnTimeElapsed = 0 lnStartSeconds = Seconds() Do While .T. If toIE.ReadyState = 4 And !toIE.Busy Do While .T. If toIE.Document.ReadyState = [complete] Return .T. Endif If (Seconds() - lnStartSeconds) > lnTimeout Return .F. Endif Enddo Endif If (Seconds() - lnStartSeconds) > lnTimeout Return .F. Endif Enddo