Clicking links in IE

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Dayclone
Newbie
Posts: 5
Joined: Wed Dec 08, 2010 11:23 pm

Clicking links in IE

Post by Dayclone » Wed Dec 08, 2010 11:29 pm

Hey guys,

I'm trying to create a script that will click on links for me automatically and select drop down menus but the issue is when I run the script I get an error on line 28 or something but I can't figure out what the issue is. Can someone please assist me.

Code: Select all

//Set up some VBS functions for use later
VBSTART
Dim IE
Sub CreateIE
  Set IE = CreateObject("InternetExplorer.Application")
  IE.Visible=1
End Sub

Sub Navigate(URL)
  IE.Navigate URL
End Sub

Sub WaitBusy
  do while IE.Busy
  loop
End Sub

Sub KillIE
  IE.Quit
  Set IE = nothing
End Sub
Sub ClickLink,(text)
  Dim FormNr
  Dim ItemNr
  Dim TheForm

  Dim anchors
  Set anchors = IE.document.All.Tags("A")
  
  if anchors.Length = 0 then
    MsgBox("No anchors found in page")
  else
    for AnchorNr = 0 to anchors.Length - 1
      Set TheAnchor = anchors(AnchorNr)
      if TheAnchor.innertext = text then
          TheAnchor.Click
        exit for
      end if
    next
  end if
End Sub

VBEND

VBRun>CreateIE

//Focus the new IE window
VBEval>IE.Hwnd,ie_handle
Let>WIN_USEHANDLE=1
SetFocus>ie_handle
Let>WIN_USEHANDLE=0

VBRun>Navigate,https://66.147.238.20:2083
VBRun>WaitBusy
Wait>1

Press Enter

VBRun>Clicklink, Continue to this website (not recommended)
VBRun>WaitBusy
Wait>1
Thanks,
Steve

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

Post by Marcus Tettmar » Thu Dec 09, 2010 9:40 am

It might help if we knew what the error message says.

It would also be easier to do this using WebRecorder.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Dayclone
Newbie
Posts: 5
Joined: Wed Dec 08, 2010 11:23 pm

Post by Dayclone » Thu Dec 09, 2010 9:19 pm

So I bought webrecorder and did my thing but I still get an error.

Here's my code that webrecorder did and I did some tweaking.

Code: Select all

// Generated by MacroScript WebRecorder 2.1
// Recorded on Thursday, December 9, 2010, at 02:25 PM
LibLoad>C:\Program Files\WebRecorder\IEAuto.dll,hIE
If>hIE=0
  MessageModal>Could not load IEAuto.dll, make sure it is in the path or edit the LibLoad line.
  Goto>end_script
EndIf

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[0]

IE_Navigate>%IE[0]%,https://66.147.238.20:2083,r
Wait>5
Press Enter
Wait>5

Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"phpMyAdmin"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,A,TEXT,str:TagValue,r

IE_WaitNew>0,IE[1]
IE_Wait>IE[1],r

IE_Wait>%IE[1]%,r
Wait>delay

IE_Wait>%IE[1]%,r
Wait>delay

IE_Wait>%IE[1]%,r
Wait>delay

IE_Wait>%IE[1]%,r
Wait>delay

LibFree>hIE
Label>end_script

The error I get is this:

Code: Select all

Line: 22 Error Calling DLL - Possible Wrong Number or type of parameters.
Please advise.

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

Post by Marcus Tettmar » Thu Dec 09, 2010 9:59 pm

I can't debug here because that site is private so I cannot access it and run your script. But I would be happy to get together with you and do a BeamYourScreen session so that we can take a look on your desktop (or you could email me a restricted login off list if you like).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Post by Marcus Tettmar » Thu Dec 09, 2010 10:04 pm

BTW - you never did reply to my first response with the exact error message with the first code sample. I was ready to help you solve the initial problem.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Dayclone
Newbie
Posts: 5
Joined: Wed Dec 08, 2010 11:23 pm

Post by Dayclone » Thu Dec 09, 2010 10:12 pm

I understand I didn't answer your first question. I just went right to the second option which seemed to be better...

So to answer your last question.
I will PM you the private logins.

Thanks,
Steven

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

Post by Marcus Tettmar » Fri Dec 10, 2010 10:39 am

I have replied to your PM with a script that works for me.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Dayclone
Newbie
Posts: 5
Joined: Wed Dec 08, 2010 11:23 pm

Post by Dayclone » Fri Dec 10, 2010 1:52 pm

Thanks, and I guess for everyone to know here's the script but I have removed the link, username, and password for security purposes.

Code: Select all

// Generated by MacroScript WebRecorder 2.4 
// Recorded on Friday, December 10, 2010, at 10:36 AM 

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt 
MouseMove>0,0 
Let>delay=1 
IE_Create>0,IE[0] 

//navigate to main page and then clicking on phpMyAdmin is pointless. We can go direct ... 
IE_Navigate>%IE[0]%,https:/INSERTLINKHERE.html,r 
IE_Wait>%IE[0]%,r 
Wait>delay 

//click on the continue to website warning (IE8/9? May have to change for your IE version) 
IE_ClickTag>%IE[0]%,,,A,TEXT,Continue to this website (not recommended).,r 
IE_Wait>%IE[0]%,r 
Wait>delay 

//windows security box will appear, may need to alter window title for your IE version 
WaitWindowOpen>Windows Security 
SetFocus>Windows Security 
Wait>0.5 
Send>USERNAME
Press Tab 
Send>PASSWORD, 
Press Tab 
Press Enter 
WaitWindowClosed>Windows Security 

IE_Wait>%IE[0]%,r 
Wait>delay 

Wait>2 

IE_Wait>%IE[0]%,r 
Wait>delay 


//Now we should be on the phpMyAdminPage 

LibFree>hIE 
Label>end_script
This is for anyone that needs to access Cpanel.

Dayclone
Newbie
Posts: 5
Joined: Wed Dec 08, 2010 11:23 pm

Post by Dayclone » Fri Dec 10, 2010 4:10 pm

mtettmar

I'm still having an issue...
Please see your PM.

I go to import and I used web recorder but it doesn't seem to open the browse button and select a file for me.

Thanks,
Steven

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

Post by Marcus Tettmar » Fri Dec 10, 2010 4:29 pm

File upload boxes cannot be scripted via DOM scripting - Microsoft prevent scripting of file upload boxes for security reasons. So, just like the password box, we have to revert to traditional keyboard simulation. Give me a few moments and I will answer your PM.
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
cron
Sign up to our newsletter for free automation tips, tricks & discounts