Jump to content
Macro Express Forums

How Do I Click A Button On A Webpage?


Grark

Recommended Posts

I had written over 100 macros to make my job easier over the last years. Fantastic program.

 

We recently moved systems from a fat client (everything clickable, tabbable, set window locations) to a new web-based system completely dynamic and mouse driven.

 

ALL my macros now have to be re-written.

 

Ok I can handle that. This new version is web-based (an area I've never written any macros on) and I'm running into troubles "screen scraping".

 

How do I capture a button? What criteria do I use? How do I send a "do this" command to the web-browser without a mouse-click? Any additional help using a web-browser to capture/return information (without keystrokes) is appreciated.

 

Yo Grark

Link to comment
Share on other sites

Welcome to the group Grark!

 

Keyboard tabbing is your only solution at this point. However, Paul and I are currently working on a solution that can be added to the PGM Functions Library. It will provide the user with information on what can be clicked on, table data, and so forth. In other words, screen scraping and data mining via Macro Express will be a reality as soon as we have it completed. Unfortunately we do not anticipate having something to release for a few weeks yet. We might be able to have something ready earlier, but it would be only for IE.

Link to comment
Share on other sites

  • 3 weeks later...
Grark: Are you still looking for a solution?

We have implemented screen scraping and classification with macro express

It now reliably controls web and citrix applications

You may be able to use elements of it in your application

Grark: Are you still looking for a solution?

We have implemented screen scraping and classification with macro express

It now reliably controls web and citrix applications

You may be able to use elements of it in your application

 

I would be interested in whatever you have cooked up that would make it easier to identify webpage data.

 

I have managed to "log" to one webpage email using ME where the titlebar has unique title info. It logs in and then the title changes and the macro ends. On another site, the titlebar remains the same (log in type text in titlebar) and so ME logs in but then the macro finds the titlebar unchanged and it flings my "log in" macro text into the ether again and again with unpredictable results.

Link to comment
Share on other sites

  • 4 weeks later...

I know it's sleezy but I too was having troubles clicking ot typing in a webpage. Problem with tabbing was that the content would vary and the tab count would be wrong. So then I would do a find with CTRL+F and ENter. THis woudl highlight the bit of desited text. Then it was a single tab to the field or button. SO for instance I could search for "user name:" and t would position me in front of the user name field so all I had to do was single tab to the field. Like I said, it aint perty but it was all my wee little brain could come up with.

Link to comment
Share on other sites

I am an Adminstrator of a web forum exactly like this. I have to edit a bunch of posts in that forum. Here is my requirement.

 

I have that web page opened already to be edited.

 

I need to run a macr to find the edit button on that web page and click it.

 

After this wait for the web page to open up that post. Now clkick on the post and select it by CTL+A. then paste it in another box on that edit page. Can this be done using MAcro Express.

 

I am a newbie and do not have much exposure to html or webn development. these Edit function has to be repeated on the opened web page until no other Edit buttons found.

 

Any help will be really appreciated.

Link to comment
Share on other sites

Hi!

 

I haven't tried yet; but Cory's idea in this thread might work; (I have seen others try to find the buttons by matching pixels from the screen; search the site "pixels"?)

 

the script below doesn't quite work yet ((gets confused where the next "tab" is, but the logic should work if you're really determined to get it going?)

EDIT - removed as not working; let me know if you need it

See post below for file working from source (no longer needs MEBasic)

Best, Randall

Link to comment
Share on other sites

Wow, something I suggested was actually worthwhile to someone? Kewl.

 

I also wanted to share another trick I have with links. I do a CRTL+F for text hyperlinks too. But here’s the trick, you have to do a SHIFT+TAB TAB to backup one and then forward again in order to highlight the link properly. Then you can just hit ENTER and it follows the link. Works for anything with searchable text. And if it's the first that still works.

 

As is always the case with web pages timing seems to be a trick but I’m sure that’s all covered somewhere else.

 

Oh, here’s another one I use sometimes. Don’t forget you can use the “View Source”. You can get several bits of characteristic info from there. For instance if they use the same graphic all the time for a link button simply search for that file name. Then grab the link URL next to it and use the normal web launching command. Nice thing about HTML is that the tags are very consistent making it easy to find and parse. Also you don’t have to wait for pesky macromedia adverts to mess you up. And of course there are many different sorts of things like this in the raw HTML that one can use and then go elsewhere with.

Link to comment
Share on other sites

hi again, Cory,

 

The Source idea was great!

 

Here is a better macro which works for any Edit buttons on the current thread. It adds the line "Could duplicte" or similar to each post with the edit button showing.

 

I use MEBasic and the Wizard for my string handling, but you get the gist..... (links in Signature)

Activate Window: "- Microsoft Internet Explorer"

Variable Set String %T1% from Window Title

Variable Modify String: Save %T1% to Environment Variable

Delay 100 Milliseconds

Text Type: <ALT>vc

Wait For Window Title: "index"

Repeat Start (Repeat 100 times)

  Activate Window: "index"

  Text Type: <CONTROL>f

  // Repeat hunt for Edit Post" then Edit Window; 10 times

  Wait For Window Title: "Find"

  Text Type: <ALT>nalt='Edit Post'

  Delay 100 Milliseconds

  Text Type: <ALT>f

  Delay 100 Milliseconds

  If Window Title "Notepad" is on top

    Text Type: <ESC>

    Wait For Window Title: "Find"

    Delay 100 Milliseconds

    Text Type: <ESC>

    If Variable %N1% = 1

      Text Box Display: Stopping now

      Macro Return

    End If

    Text Box Display: Exiting now

    Repeat Exit

  End If

  Text Type: <ESC>

  Wait For Window Title: "index"

  Text Type: <ARROW LEFT><SHIFTD><ARROW UP><ARROW UP><ARROW UP><ARROW UP><ARROW UP><SHIFTU><CONTROL>c

  Variable Set String %T2% from Clipboard

  Replace "&" with "&" in %T2%

  // #Region --- MECodeWizard generated code Start ---Mid$ Between Search  --->MEBasic

  Variable Set String %T1% "BtwCharMid$["%T2%","href",1,1,">",-1,-1]"

  Macro Run: {_Basic ME Lite1}

  Variable Set String %T2% from Environment Variable

  Variable Modify String: Save %T2% to Environment Variable

  // #EndRegion --- MECodeWizard generated code End ---BtwCharMid$

Repeat End

Window Close: "Notepad"

Variable Modify Integer: Dec (%N1%)

Repeat with Variable using %N1%

  Variable Set String %T2% "Edit_%N1%"

  Variable Set String %T2% from Environment Variable

  Web Site: %T2% [Default Browser - Wait to load]

  If Window Title "Editing" is on top

    Text Type: <TAB><TAB><TAB><CONTROL><END><CONTROL><SHIFT><HOME><CONTROL>c

    Text Type: <CONTROL><END><ENTER><ENTER>

    Text Type: <TAB><ENTER>

    Wait Window Lose Focus: "Editing"

    Wait For Window Title: "%OriginalWindowTitle%"

    Window Close: "%OriginalWindowTitle%"

  Else

    Text Box Display: Unexpected Window

  End If

Repeat End

Activate Window: "%OriginalWindowTitle%"

Text Type: <F5>

Best, Randall

EDIT -PS Cory, do you have some examples to share?

***** ==== (presently needs MEBasic else crash) ***** =========

WebEditButtons.mxe

Link to comment
Share on other sites

I have many special purpose macros but I'm a hacker and rarely organize and remark properly so they're quite ugly and not ready for public scrutiny. You should have seen the one I made for eBay to fill out the UPS shipping form from my database after they went to the multipage input model. Geez, that was ugly. Then eBay/PayPal decided to offer one to generate shipping labels which complete negated the need for my macro. Now that was a waste of time! <g> Then there was the one I wrote to download all the messages from a Yahoo group. All 34,000 messages which, just to foil such a thing, Yahoo inserts periodic disrupter pages so one can't simply plow thru the messages by the numbers. So I had to ID those and other things like avoid download quotas by periodically resetting my router from the macro in order to get a fresh IP address. Then it saved them all as text files and stripped out all the garbage and left a bunch of pretty text files. Of course half way thru my 4 day ordeal Yahoo decided to 'revamp' the look of their website and changed everything around! It was cool though, at one point I was distributing the tasking to machines in multiple offices and using FTP to coordinate their efforts by downloading blocks of 1000 at a time. Very cool.

 

In the future if I make something cute I'll try to make it more presentable and post it up here. I should make them nicer anyway becasue I often come back to them later intending to tweak what I had stop in my tracks thinking "What madman wrote this?"

 

Hey, do you have any validation routines?

Link to comment
Share on other sites

Hi Cory and Randal,

 

Thx for Ur prompt reply. As I said earlier I just installed the Macro express for this forum edit functionality yesterday.

 

What do I do with the mxe file u have provided?

 

Tabbing didn't work. I will try looking into the source code as per cory's suggestion. Letz say if the Edit buton is represented as EDIT.gif then can I just do CTL+F and EDit.gif to get to the edit button??/?

Link to comment
Share on other sites

Hi,

Yes, it is confusing.

If you would like to try my working macro, you will need to follow instructions below; let me know if not clear enough.

 

1. Download MEBasic current version "mex" (not mxe) library, eg to desktop, double click on it (replaces your current macro file library, but leaves it intact to reload later (Menu / File/Reopen/1 (or "macex.mex" in a certain directory as shows at the top of the ME Editor). (Go to the forum location for download from the link in my signature "Basic ME".)

[Actually, to make it easy, download it from here as latest version, and I have included it]

ME Basic zip

Discussion if needed

[Normally, you would then; 2. Download the "WebEditButtons.mxe", and import it into the library; Menu / File/Import/Import a playable Macro/ select from Desktop or wherever you downloaded it)

 

3. Open your Web page

 

4. Run the macro (Hotkey is set as "Alt-Control-W)

 

Let me know if not working!

 

Best, randall.

PS I "nearly" had it working the other way, by tabbing, and could have got there in the end, I think.

Using source, you do not "click" on the button, you extract the address, and use it in the WebPage open command; = You will see that I Selected in source "alt='Edit', then 5 lines up to a string, then cut out the URL between href and ">". My string handling in ME Basic just saves the extra string handling macro.

In the code above,

  Text Type: <CONTROL>f

  // Repeat hunt for Edit Post" then Edit Window; 10 times

  Wait For Window Title: "Find"

  Text Type: <ALT>nalt='Edit Post'

  Delay 100 Milliseconds

  Text Type: <ALT>f

 

(Even if it is working, you will need to modify the lines when the Editing page is open; all I do is "cntl-ENE, insert a line, tab to submit button and press enter; you would need to "crtl-a", copy, tab to the window you want, paste, tab to submit button; )

Best, Randall

Link to comment
Share on other sites

Hi again!

This version is "spiffier", doesn't search in Notepad (only copies the source and closes)

 

It also does not need MEBasic MEX, and so can even run standalone on your desktop as a demo of opening and shutting sites etc. you would still need to import it to your own macro library for editing to make it do as you want in the Edit site!

 

Otherwise the same; in your own scripts, add the timing frequently , extra 1/2 sec delays for copying and tabs may help.

Best, Randall

WebEditButtons3.mxe

Link to comment
Share on other sites

Let me give you an example of the find and tab first. Let's say to the left of the "Edit" button there was a string of text "User information:". I would search the web page with a CTRL+F and enter "User information:" in the text box followed by ENTER. Now "User information:" will be highlighted. Since the next hyperlink on the page is the button I want to click all I have to do is Text Type a TAB and now the “Edit” button will be highlighted. Now just TT an ENTER.

 

<HTTP2:2:T:https://manage1.sprintpcs.com/Manage><TEXTTYPE:<CONTROL>f ><WAITWIN2:000010:000000:Find ><MSD:500><TEXTTYPE: PCS Phone Number: ><MSD:500><TEXTTYPE:<ENTER> ><MSD:500><TEXTTYPE:<ESC> ><MSD:500><TEXTTYPE:<TAB>7605551212<TAB>Password<ENTER> >

 

This is one I use in a larger macro to go to my cell phone bill as an example.

Link to comment
Share on other sites

For the "View Source" option I simply pop open the webpage and search for an identifying string of text like the link text or graphic. Then I copy the line to my clipboard and parse out the "HREF" part which is the link. Then I simply launch that in a new web window.

 

Obviously the link you need to follow must be variable or you could simply launch the URL. Usually you can find text to use as a keystone but sometimes it's difficult. Nice thing about forums and such is that they are consistent and there's usually a direct way to URL. For instance you might not actuality need the URL under the edit button. Sometimes you can find a message ID or something and use a standard databasey URL link. Like eBay. Let’s say a webpage has a bit of text “Leave feedback for item ??????????” someplace where the Q marks are the item number. Well simply search for that and arrow over and highlight the ebay item number and launch that with http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item= in front of it and you will have it. You didn’t want to leave feedback, you were just using it as a keystone to do something else.

Link to comment
Share on other sites

Grark: Are you still looking for a solution?

We have implemented screen scraping and classification with macro express

It now reliably controls web and citrix applications

You may be able to use elements of it in your application

To ol3ears:

I posted a private message to you concerning this message. Did you receive it?

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...