Jump to content
Macro Express Forums

Feature suggestion


Recommended Posts

Hi. One thing I think would be really, really useful would be if Macro Express could compare a portion of the screen to a saved image. If you were working in scripting editor for example, under the logic section it would be "If Screen Image" which would give you a dialog where you enter the path/filename of a bitmap then the upper left corner X and Y coord to start comparison. The system could then, at runtime, read the file to determine the file's width and height then use the start X/Y to get the current screen image and compare to the bitmap.

 

You could also make something akin to the mouse move's mouse locator for use with that. You hit a button to launch the screen clipper then you move the mouse to the upper-left corner of where you want to cut, right click to start, then move the mouse to the lower right corner of the selection and right click again then the system would automatically save it as a bitmap and automatically enter the start X/Y coords and stuff.

 

Reason being, when I want my macro to operate a website I have pages where if you click a link, the next page loads in half a second but sometimes it takes 13 seconds! I have to code my macro to wait the maximum possible length, and this highly screws my efficiency on days when the page is loading fast. If I had a logic I could do a loop until a screen portion I clip matches the image file then continue processing the macro.

 

That'd be sweeeeeet, please please consider it :)

 

Thanks!

Link to comment
Share on other sites

There are ways -- albeit indirect ways -- to infer when a Web page has loaded. It usually takes fancy scripting, and the resulting scripts are never 100% reliable. In general, I try to avoid time delays in scripts, but I find that these kinds of macros need strategic pauses to boost reliability, and as an insurance policy against the unpredictability of Web. But excellent reliability is achievable.

 

Approaches I have used include:

 

1. Monitor a single pixel for a colour change.

 

2. Monitor a line of pixels for a colour change.

 

3. Monitor a rectangle of pixels for a colour change.

 

4. Monitor changes in the shape of a mouse pointer at a pixel, along a line, or in a region.

 

What and where you monitor depends on a lot of factors: the browser and its version, system settings, the Web site, and more. I have not found one approach that works on all pages and under all conditions. My most elaborate script for determining when a Web page has fully loaded uses pixel searches to calculate the dimensions of the address line, and tests for a range of pixel colour changes along its height. Although the script works when I switch screen resolutions or plug in a different monitor, I would not expect it it to work on a different computer!

Link to comment
Share on other sites

This would be quite straight-forward to do with ME right now! The logic is not difficult.

 

Really? I didn't see any options in the scripting editor that sounded like it would work. If you mean using the IE section to wait for web page to load, that's not really do-able since the website is showing as loaded all the time, the changes I have to wait for are in some type of flash or script or something.

 

 

 

There are ways -- albeit indirect ways -- to infer when a Web page has loaded. It usually takes fancy scripting, and the resulting scripts are never 100% reliable. In general, I try to avoid time delays in scripts, but I find that these kinds of macros need strategic pauses to boost reliability, and as an insurance policy against the unpredictability of Web. But excellent reliability is achievable.

 

Approaches I have used include:

 

1. Monitor a single pixel for a colour change.

 

2. Monitor a line of pixels for a colour change.

 

3. Monitor a rectangle of pixels for a colour change.

 

4. Monitor changes in the shape of a mouse pointer at a pixel, along a line, or in a region.

 

What and where you monitor depends on a lot of factors: the browser and its version, system settings, the Web site, and more. I have not found one approach that works on all pages and under all conditions. My most elaborate script for determining when a Web page has fully loaded uses pixel searches to calculate the dimensions of the address line, and tests for a range of pixel colour changes along its height. Although the script works when I switch screen resolutions or plug in a different monitor, I would not expect it it to work on a different computer!

 

The pixel color check is a built in function of ME? Where is that option? That would be fine for what I need; simply seeing a color change would tell me what I need.

Link to comment
Share on other sites

Really? I didn't see any options in the scripting editor that sounded like it would work. If you mean using the IE section to wait for web page to load, that's not really do-able since the website is showing as loaded all the time, the changes I have to wait for are in some type of flash or script or something.

I was simply addressing the feature you wanted Insight to create for you:

One thing I think would be really, really useful would be if Macro Express could compare a portion of the screen to a saved image

which is nothing much to do with waiting for a web poage to finish loading, though it could be used for that purpose.

You'd need to create a text file of all the colours in the screen portion of interest using the same format as ME, e.g.

16777215,5387805,0
1677210,5384001,0

which would represent an area of 2 rows of 3 pixels.

 

Then you'd write a macro to compare the contents of this text file against the desired portion of your screen, one pixel at a time (you could omit the commas, though they do help readability).

I do something similar quite often.

 

If you're interested in waiting for an IE page to complete, then you should take a look at AutoIt, which contains a user-defined library of functions written specifically for IE (only IE, no other browser). For example you could use this AutoIt code:

#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php")
_IELoadWait ($oIE, 0, 300000)

which would load the web page "http://www.autoitscript.com/forum/index.php", and return control to you only when the page has loaded, or it fails to load within the specified timeout of 300,000 milliseconds. I don't use IE myself, so don't know whether this will detect Flash-based activity; but I do know the author of all the AutoIt IE stuff, and would guess it does.

Link to comment
Share on other sites

I agree the feature Strahan wants would be very useful. I put in a feature request for it about 6 months ago, tracking number [iSS8287]. There is a macro program with exactly that feature, called Macro Scheduler, sold by MJT Net Ltd. (in Merry Olde England, I think).

 

It's true you can do a lot with ME by checking specific pixels, especially if you KNOW what window is to be loaded. But if any one of a dozen windows might potentially be loaded, all with the same window title, you end up building color maps of all of them, storing the maps in a file, and writing complicated (and slow) logic to read back the file and check many pixels per potential window. An image-recognition feature would be a lot easier.

Link to comment
Share on other sites

 

The pixel color check is a built in function of ME? Where is that option? That would be fine for what I need; simply seeing a color change would tell me what I need.

 

Under "System," you will find "Get Pixel Color," which assigns a pixel colour to an integer variable. To test it, use "If Variable ..." Use the "Mouse Locator" to determine pixel colours.

Link to comment
Share on other sites

Ahh, excellent. My macro works alot better now that I've implemented that. One follow up question.. I wrote another macro to assist me in adding friends to Facebook. I play a game that requires you have to friends for more stuff in the game (God that's annoying). There is a group where people post up if they want to be friended, so I go down the list middle-clicking each profile until Firefox has like 20 tabs open with each person's FB page. I then ctrl-tab to each tab, hit "Add Friend" then send. Problem with macro'ing it is the "add friend" button moves based on the length of the person's name since the button is after the name. So right now I have:

 

fbmacro.jpg

 

Repeats 1130 to 0, step -2. As it "slides" from the far right to the left if it sees the color of the add friend button, it adds the friend but if it can't find it just closes that person's profile and goes to the next. Works fine, but not very fast. Any more efficient way to do that?

 

PS.. the tolerance between the far right border of the btn and the "d" in add friend is like 5px, so I can't safely boost the skip by any more than 2.

Link to comment
Share on other sites

If you're interested in waiting for an IE page to complete, then you should take a look at AutoIt, which contains a user-defined library of functions written specifically for IE
I have been using with great success VBScript automate IE via it's API. It's amazingly simple and way better than all these painful MEP methods. But in there they have two different wait commands that most of the script gurus use. There's one for load and another for document ready or some such thing. So far it has worked flawlessly. And filling out form field is simply setting object properties so it's nearly instantaneous. In fact by the time you see it the form is already populated with your data.

 

But I too have created many macros that scan pixel colors in certian ways. I've even done ones that will hunt for moving buttons...

Link to comment
Share on other sites

I don't think VbScript is being developed any more; you may not care, but it's not going anywhere.

The problem with any VbScript approach is that it's written by Microsoft, whereas the AutoIt stuff has been developed by a first-class guy who has done this not for money - I know which approach I prefer! I've worked a bit with this developer, and can personally vouch for him - he's first-class.

Link to comment
Share on other sites

I heard rumor that there will be no more development of AutoIt. I haven't tried to confirm, however.

Here's the word:

"What I know is that there is a tiff between a couple of the AutoIt developers and it has not yet been amicably resolved. It may not play out well, but I think it is too soon to say. They may work it out and there may be others who can fill the shoes. Not pleasant at the moment, but I don’t think that development is doomed by any means at this point."

Link to comment
Share on other sites

%N1%, %T1%, %D1% are the only arrays available for Macro Express 3.x. You cannot specify %N[1]% in ME3; you're probably thinking about Macro Express Pro.

 

To add to the confusion, if you import an ME3 script into MEP, all the %N1%, %T1% variables get converted to %N[1]%, %T[1]% <_<

 

Anyway, I'm glad there are named variables in MEP!

 

 

Your variable names are a bit odd! Instead of %N1%, %T1%, etc., you ought to be using %N[1]%, %T[1]%! Your %N1% is a different variable to %N2%, whereas I'm using the first 2 elements of an array called N or T.

Link to comment
Share on other sites

%N1%, %T1%, %D1% are the only arrays available for Macro Express 3.x. You cannot specify %N[1]% in ME3; you're probably thinking about Macro Express Pro.

That would be because this is a Macro Express Pro forum, and I don't expect to find ME3 messages in 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...