User ID and Password

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Guest

Post by Guest » Mon Jan 31, 2005 4:39 pm

Inserted a one second wait before submit and that seems to have cured it. It seems that the thing was trying to run over itself. Broadband connection faster in the day than the evening. Thanks once again. :D

Guest

Post by Guest » Mon Jan 31, 2005 4:48 pm

hmmm, spoke too soon. I had a window open viewing this board when It worked so it seems that it will only work when another instance of IE is running and it doesnt have to be on the same site. Doesnt make sense.

Guest

Post by Guest » Mon Jan 31, 2005 6:33 pm

Following a process of elimination, I have found that the problem is not with the script at all. I have tried to manually log into the site and it still returns the login window but randomly accepts the login. Must be a problem server side. This seems strange as my wife also has a login and password and has no problems on the same machine. Anyone seen this before?

Sarah
Newbie
Posts: 4
Joined: Tue Feb 22, 2005 10:45 am

Post by Sarah » Tue Feb 22, 2005 10:59 am

Hi MJT Net Support
You so very kindly helped my colleague out with the script for logging into the website we use. The script will no longer click the login button. We are new to this but have looked long and hard and tried everything to try and fix this before posting but with no joy. Im told that it is probably something very simple. Is it because the button has been changed to a rollover? Would be most grateful for you help.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Feb 22, 2005 11:18 am

Hi,

It is impossible to say without seeing your script and the site in question. Feel free to post your code here (or send it to [email protected]) with a link to the site you are automating.

If you are using the form submit code then the type of button should be irrelevant as the script does a form.submit. The only time that might be a problem is if the form has an object named 'submit' in which case it overrides the forms submit method and causes an error. In this case the solution is to click the submit button / or link.

Rollover 'buttons' are not buttons at all. They are links surrounding images where some javascript causes the images to change. The image and the javascript is not of interest to an automation script which would just need to be told to click the link.

You will notice that 99% of my response to your question is about html and web forms, not about Macro Scheduler. Understanding how html, forms (web applications) work is going to be crucial to the success of your macro which has to automate the web application. If you understand how the application that you are automating works then you will be closer to getting your script to work.
MJT Net Support
[email protected]

Sarah
Newbie
Posts: 4
Joined: Tue Feb 22, 2005 10:45 am

Post by Sarah » Tue Feb 22, 2005 11:46 am

Hi,
Thanks for that. The script is below. We would be very interested to see what has changed on the page to make the submit not work now. Thanks

VBSTART
Dim IE()
Dim MaxIEObjects

Function CreateIE
MaxIEObjects = MaxIEObjects + 1
ReDim preserve IE (MaxIEObjects)
Set IE(MaxIEObjects) = CreateObject("InternetExplorer.Application")
IE(MaxIEObjects).Visible=1
CreateIE = MaxIEObjects
End Function

Sub Navigate(IEInst,frame,URL)
if frame="" then
IE(IEInst).Navigate URL
else
on error resume next
dim err
err = 0
err = IE(IEInst).Document.Frames.length
if err = 0 then
IE(IEInst).Navigate URL
exit sub
end if
on error goto 0
dim frameNr
dim frameFound
frameFound = 0
if IE(IEInst).Document.Frames.Length > 0 then
for frameNr = 0 to IE(IEInst).Document.Frames.Length - 1
if IE(IEInst).Document.Frames(frameNr).name = frame then
IE(IEInst).Document.Frames(frameNr).navigate URL
frameFound = 1
exit for
end if
next
end if
if frameFound = 0 then
IE(IEInst).Navigate URL
end if
end if
do while IE(IEInst).Busy
loop
End Sub

Sub KillIE(IEInst)
IE(IEInst).Quit
Set IE(IEInst) = nothing
End Sub

Sub DoForm(TheForm,fieldname,fieldvalue,submit)
Dim ItemNr
for ItemNr = 0 to TheForm.Elements.Length - 1
if TheForm.Elements(ItemNr).Name = fieldname then
TheForm.Elements(ItemNr).Value = fieldvalue
If submit=1 then
Dim SubItems
Dim FoundSubmitButton
FoundSubmitButton = 0
for SubItems = 0 to TheForm.Elements.Length - 1
if UCase(TheForm.Elements(SubItems).Name) = "SUBMIT" then
if UCase(TheForm.Elements(SubItems).TYPE) = "SUBMIT" then
TheForm.Elements(SubItems).Click
FoundSubmitButton = 1
Exit For
end if
end if
next
if FoundSubmitButton = 0 then
TheForm.submit
end if
end if
exit for
end if
next
End Sub

Sub FormFill(IEInst,frame,fieldname,fieldvalue,submit)
Dim FormNr
Dim TheForm
if frame="" then
if IE(IEInst).Document.All.Tags("FORM").Length > 0 then
for FormNr = 0 to IE(IEInst).Document.Forms.Length - 1
Set TheForm = IE(IEInst).Document.Forms(FormNr)
DoForm TheForm,fieldname,fieldvalue,submit
Set TheForm = nothing
next
end if
else
dim frameNr
dim frameFound
frameFound = 0
if IE(IEInst).Document.Frames.Length > 0 then
for frameNr = 0 to IE(IEInst).Document.Frames.Length - 1
if IE(IEInst).Document.Frames(frameNr).name = frame then
if IE(IEInst).Document.frames(frame).Document.All.Tags("FORM").Length > 0 then
for FormNr = 0 to IE(IEInst).Document.frames(frame).Document.Forms.Length - 1
Set TheForm = IE(IEInst).Document.frames(frame).Document.Forms(FormNr)
DoForm TheForm,fieldname,fieldvalue,submit
Set TheForm = nothing
next
end if
frameFound = 1
exit for
end if
next
end if
if frameFound = 0 then
if IE(IEInst).Document.All.Tags("FORM").Length > 0 then
for FormNr = 0 to IE(IEInst).Document.Forms.Length - 1
Set TheForm = IE(IEInst).Document.Forms(FormNr)
DoForm TheForm,fieldname,fieldvalue,submit
Set TheForm = nothing
next
end if
end if
end if
do while IE(IEInst).Busy
loop
End Sub

Function ExtractTag(IEInst,TagName,Num,all)
dim t
set t = IE(IEInst).document.getElementsbyTagname(Tagname)
if all=1 then
ExtractTag = t.Item(Num).outerHTML
else
ExtractTag = t.Item(Num).innerText
end if
End Function

VBEND

Let>delay=1
VBEval>CreateIE,IE[0]
VBRun>Navigate,%IE[0]%,,http://www.retaileyes.co.uk/home/userlogin.php
Wait>delay
VBRun>FormFill,%IE[0]%,,username,user,0
VBRun>FormFill,%IE[0]%,,password,pass,0
VBRun>FormFill,%IE[0]%,,j,,1

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Feb 22, 2005 12:03 pm

Hi,

Looks to me like the hidden field, j, has been removed. Remove the last line of the script and change the 0 to 1 on the penultimate (now last) line. So the last two lines should be:

VBRun>FormFill,%IE[0]%,,username,user,0
VBRun>FormFill,%IE[0]%,,password,pass,1

Try that.
MJT Net Support
[email protected]

Sarah
Newbie
Posts: 4
Joined: Tue Feb 22, 2005 10:45 am

Post by Sarah » Tue Feb 22, 2005 12:38 pm

Many thanks, of course that worked perfectly. We didnt understand what the j was for. How could you see that there was a hidden field and that it had been removed? Do we see it in the source somewhere? We are trying to understand your steps to solving this so we may have a better chance in the future. But im sure you have better things to do than give HTML classes to beginners.
Many thanks again for your help.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Feb 22, 2005 12:44 pm

Hi,

Yes, just look at the source. Look for the code between and and check out the form elements.
MJT Net Support
[email protected]

Sarah
Newbie
Posts: 4
Joined: Tue Feb 22, 2005 10:45 am

Flash button

Post by Sarah » Tue Feb 06, 2007 12:04 pm

Hi, you kindly helped me out with the login macro in this thread. The site has changed the submit button into a flash button. Can you tell me how to alter the marcro to submit to this flash button please?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 06, 2007 12:09 pm

Hi,

The only way to automate a Flash component would be using image recognition:

http://www.mjtnet.com/imagerecognition.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts