Jump to content
Macro Express Forums

Macro to click specific links?


BrandonTerry

Recommended Posts

Good day!

 

Our company works with several websites--2 in particular--that require us to click various navigational links.

 

Usually, I can create a macro to use CTRL F, type what is needed to search, and CTRL ENTER to actually click the link. However, in the case of these 2 websites, all links say the same statement and the color does not change when the links are clicked.

 

Would their be a way to create a macro that would go to a hyperlink based on the javascript code? If this link has this ID in the code, then this...?

 

Thank you in advance!

 

Brandon

Link to comment
Share on other sites

A simpler approach may be to search for text near the link or field you are trying to get to. Then tab or shift+tab to your target. Maybe something like this (in pseudo code)

 

Text Type "<CONTROL>f" ' initiate search

Text Type "Personal Info" ' search for this text

Text Type "<ESC>" ' cancel the search

Repeat 10 Times ' navigate to the 10th screen object

Text Type "<TAB>"

Repeat End

Link to comment
Share on other sites

Hi, Alan! Thanks for the quick response! Unfortunately, this will not work. The website is a state employment website that contains a list of all clients we represent. The first column contains the hyperlinks with the same phrase--Work on this Employer. The column next to it contains the corresponding company EIN's. I've tried your suggestion prior to posting. Unfortunately, when I manually press ESC, it skips all "Work on this Employer" links. It's a crazy website that, unfortunately, 2 states use!

Link to comment
Share on other sites

Macro-powered workarounds for navigating poorly-coded web pages are often possible; but it takes effort to figure them out. Here are some methods I have used:

 

1. Check the code to see if the developers included accesskey attributes. For example, view the HTML for this site:

 

http://directory.utoronto.ca/phonebook/pages/admin/main.xhtml

 

...and you will discover "1" and "2" are access keys for two fields. To navigate to the "Last Name" field in IE, press Alt + 1, or in Firefox, press Shift + Alt + 1.

 

2. Through trial and error experimentation, see if there are areas of the screen that, when clicked on, reliably move keyboard focus to a nearby screen object. In other words, click at (x, y), and then press Tab to move to certain fields. These "neutral areas" can sometimes be found in the margins of a page, e.g., pixel (1,1) as measured from the top left corner of the viewport.

 

These actions can be translated into MEP scripts.

 

3. See if you can navigate to the target field by pressing Tab (or Shift + Tab) enough times. Something like this might work:

 

Repeat 44 Type <Tab>

 

...or maybe

 

Repeat 44 times

Type <Tab>

Wait 20 milliseconds (a delay may help with reliablity)

 

4. Press F6 (or Shift + F6) to move from frame to frame.

 

5. Combinations of the above... for example...

 

Move mouse relative to the text cursor position (which in some browsers, is the upper left corner of the viewport).

Move mouse (1, 1) relative to the last position (to get to a "neutral area")

Mouse Click

Type <F6><F6> (to move to the third frame)

Type <Tab> 40 times (to reach the desired field)

Link to comment
Share on other sites

Here are two more to consider along with Alan's great suggestions:

 

6. Change the size of the browser window to allow reliable positioning of elements in the browser. Then use mouse clicks on known locations. If necessary, you can save the size of the window at the top of the macro and restore it at the end.

 

7. Alan mentioned using <SHIFT><TAB> (back tab). I have found that in some cases this can be more reliable rather than tabbing forward through the fields in the browser window. Something like this:

Text Type: <ALTD>d<ALTU>  // Move to the address field of the browser
Repeat Start (Repeat 44 times)
  Text Type: <SHIFTD><TAB><SHIFTU>  // back tab
Repeat End
Link to comment
Share on other sites

8. In some (but not all) web-based apps, the URL changes to reflect where you are. For example, for a webmail program, you might see URLs like these:

 

Inbox folder: https:// xxxxxxxxx?id=123&page=1&inbox

Sent messages: https:// xxxxxxxxx?id=123&page=1&sent

Junk folder: https:// xxxxxxxxx?id=123&page=1&junk

 

So rather than script a macro that clicks on the Inbox link, achieve the same thing by typing the URL in the address bar:

Text Type: <ALT>d // Move to the address field of the browser
Text Type: https://www.xxxxxxxxx?id=123&page=1&inbox
Text Type: <ENTER>
Link to comment
Share on other sites

  • 1 month later...

Thanks to everyone that has applied! I've asked the state office to actually put the hyperlinks on the codes instead of the generic instruction of "work on this employer." Not sure how long it will be before that happens or if it will happen though. I wonder if it would be possible to program a macro to open a link based on the link ID value. If this link has an ID of 1234, then this...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...