Jump to content
Macro Express Forums

Sect & copy text using mouse


Recommended Posts

Hi

 

I have a list of data in a table on a web page which I'd like to select and copy

 

I first place my mouse cursor at the beginning of the range (upper left hand corner),

I then hold down the left button,

and I move to the mouse cursor to the diagonnaly opposite (lower right hand corner)

and then I let go of the left mouse button

Finally I execute a clipboard copy

 

<MOUSE MOVE Option="\x01" X="800" Y="1111" _PROMPT="0x000A"/>
<DELAY Flags="\x02" Time="50"/>
<MOUSE LEFT BUTTON DOWN/>
<DELAY Flags="\x02" Time="50"/>
<MOUSE MOVE Option="\x01" X="2110" Y="370" _PROMPT="0x000A"/>
<DELAY Flags="\x02" Time="50"/>
<MOUSE LEFT BUTTON UP/>
<DELAY Flags="\x02" Time="50"/>
<CLIPBOARD COPY/>
<DELAY Flags="\x02" Time="50"/>


When I execute this, the selection heads in the opposite direction

I tried "[upper left] to [lower right]" as well as "[lower right] to [upper left]" : same result

What am I not understanding ?

 

regards

yann

 

 

Link to comment
Share on other sites

I'm sorry I don't have much time here so I can't help you with your question directly. I wanted to give you some general advice.

First is to do as few of things as possible with a mouse in web browsers. You can often grab text with a CTRL+A and then process that as text in MEP. Also I often find using the raw HTML more useful due to it's structure and labels of elements. Ctrl+U will do that in Chrome, I don't know about others. You can also navigate to a page's HTML by adding "view-source:" to the beginning of the URL. Also there's a command in MEP to get a page's contents. However this will often fail if using active web pages. 

Probably not a solution you were looking for, but you might consider this. 

 

  • Like 1
Link to comment
Share on other sites

It's really hard to make a macro like this work by simulating mouse actions.

 

If the table you want to copy is always the same size (e.g., 3 columns and 5 rows), there's a chance to you can make it work by sending keystrokes instead of mouse clicks. For example, on this page, there's a 3 x 6 table:

 

https://www.w3schools.com/html/html_tables.asp

 

If you click into the left side of the first cell, this sequence of keys will select the first three rows:

 

Shift + Down

Shift + Down

Shift + Down

 

This translates nicely into Macro Express instructions.

 

I like Cory's idea of parsing the HTML. That might make for a good challenge...

  • Like 1
Link to comment
Share on other sites

Without disagreeing with what Cory and acantor said ... your macro appears to be moving the mouse rightward and upward, rather than rightward and downward.

 

The x coordinate is horizontal, and x increases from left to right.

The y coordinate is vertical, and y increases from top to bottom. 

Also be careful whether you specify movements as relative to screen, relative to window, or relative to the current mouse position -- it's an option in the Move Mouse command. 

  • Like 1
Link to comment
Share on other sites

I don't know what you're trying to do, but you might also want to consider opening the web tables in Excel. Many times I see people go though all kinds of steps when one can simply link to the HTML tables in Excel. They're all part of the facility to link to external data and one can set the query to update with various rules like every time the Workbook is opened. Data tab in the ribbon, "Get Data", "From Web". You can navigate to the page, sometimes even password protected, and it will identify all the table and let you choose which you want to link to. So even if you're destination isn't Excel, it's easy to make a Workbook you can open with MEP that will result in a refresh of the data and everything in cells one can directly get with ease. 

BTW in Excel Use Ctrl+G to get to cells using the Windows Controls commands in MEP. You can also set up named references in Excel and they work in Go To. Like highlight the cell or cells you want and name them Fred. Now in Go To you can highlight that range of tables by putting "Fred" in the Reference field. 

Also consider if the data you are looking at is exportable in any way. In much of my scraping I will find the ability to export to a text delimited file like CSV. Even if one must do some math, or it's a huge data set, it's usually much easier to manage and the macros are more reliable.

Sorry, I don't have much experience with mouse moves. I do this professionally and I just have always been able to find away without using the mouse in a web window. In fact I can't remember the last time I used a mouse move command in any macro. 🙂

Just a couple random ideas to consider. Sometimes it's more efficient to go around a mountain than over it. 

  • Like 1
Link to comment
Share on other sites

Quote

In fact I can't remember the last time I used a mouse move command in any macro.

 

I agree with Cory. When writing macros, with few exceptions, manipulating the mouse pointer is asking for trouble -- even when it's possible. Although not a method most people are comfortable with, figuring out how to perform a task via keyboard will get you further.

 

Parsing the HTML, as Cory suggested, is a fantastic method, but you need to possess, or be willing to learn, elementary computer programming skills.

  • Like 1
Link to comment
Share on other sites

I do not. But if you have an example I can give some pointers and show a few simple examples. For instance one thing to look for are labels. HTML is made of of elements.  "Table" is a type of element. They support attributes and one of them is an ID. A good web programmer will name all of these elements and they shoudl be unique on a page. So you might find a table element id="Annual Values" and that's a great way to set a start point. Or find anything that will be unique. Of course this only applies when the content of the web page before this changes. Otherwise you can go right to the prize. 

Also if it's structured well with each element of the form on separate lines, simply processing the HTML line by line works well. 

I haven't done this for years so I might be a little rusty. Long ago I learned RegEx and use it almost exclusively. In the early days of computing programmers often had to process unstructured text often and some smart guys designed this text processing engine and it's wonderful. Unfortunately it's hard to learn and one would need to use an external script to access it in MEP. But if anyone gets into something really big and wants to know more, feel free to contact me. 

So post some basic HTML samples and I'll give you some pointers for MEP. 

Link to comment
Share on other sites

You could also consider using the HTTP Get macro command. You would still need to parse the HTML.

 

Sample:

HTTP Get: https://www.macros.com to %WebPage%
Text Box Display: Webpage

 

<HTTP GET Option="\x00" URL="https://www.macros.com" Destination="%WebPage%" NoEmbeddedVars="FALSE"/>
<TEXT BOX DISPLAY Title="Webpage" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %WebPage%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1591" Height="768" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

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