
User ID and Password
Moderators: JRL, Dorian (MJT support)
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?
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.
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.
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.
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]
[email protected]
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
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
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.
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]
[email protected]
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.
Many thanks again for your help.
Hi,
Yes, just look at the source. Look for the code between and and check out the form elements.
Yes, just look at the source. Look for the code between and and check out the form elements.
MJT Net Support
[email protected]
[email protected]
Flash button
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?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
The only way to automate a Flash component would be using image recognition:
http://www.mjtnet.com/imagerecognition.htm
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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?