PDA

View Full Version : VB6 programme query


BOAC
5th May 2008, 21:38
I have hacked the 'load a web page and move around it' bits, but cannot write the lines to click 'Yes' on a web certificate acceptance warning panel ('Security Alert'). Help appreciated!

Hyph
6th May 2008, 14:19
Record a macro to click the button (use keys, rather than mouse) and call the macro from VB6?

BOAC
6th May 2008, 16:43
Sounds good, Hyph, but treat me as someone with a white stick and guide dog:) I do not really know where to start!

I have constructed an example script here (NB secure site plucked at random). NB I am using the VB web browser control.
+++++++++++++++++++++++++++++++++++++++++++

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVallpWindowName As String) As Long

Private Sub Form_Load()
WebBrowser1.Navigate ("https://www.capitaloneonline.co.uk/CapitalOne_Consumer/Login.do")
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Object) Then
SendKeys "{TAB 1}"
SendKeys "Hello World"
End If
End Sub
+++++++++++++++++++++++++++++++++

and up comes a similar window asking if I wish to display insecure items. So, apologies for the ignorance, but how do I record AND INCORPORATE a macro to send 'Yes' or tab to 'yes' and 'Enter' or ALT Y........................ to that window?

Hyph
7th May 2008, 10:38
Hmmm... I was afraid you'd ask that! :{

I got out of developing (and some would say, real work :ok:) over 10 years ago. I think VB3 was the flavour du jour the last time I looked at it, so my ability to help you directly is limited.

I have had a more serious think about what you're trying to achieve.

My original suggestion of using a macro might not work in your case. I don't remember if VB itself has a macro recording capability - usually found on a menu option "Tools... Macro... Record New Macro" with a video recorder style 'record' button. If not, you might need a third party app, such as iMacros.

Note that VB for Applications (VBA) allows you to record VB Script macros in Excel, Word, Powerpoint and Project - but unfortunately not IE.

However... macros aside, there may be other ways to achieve your goal.

I presume, as you hard-coded the site in your example, that the site you are trying to open is the same site each time.

If that is the case, perhaps you should set IE (or whatever browser you're using) to accept the security certificate by default. In IE, go to Tools... Internet Options... Security tab and add the site to your list of Trusted Sites.

Alternatively, I think I also found a VB.net solution to your problem which I'll PM to you, as I can't provide a link here (because it's on ******** dot com).

As it's VB.net it might not work directly in VB6, but perhaps you can get it to work with a little code tweaking.

Hopefully one of these will help.

Hyph.