Jump to content
Macro Express Forums

Get Pixel Colour Beneath Mouse - Incredibly slow


Recommended Posts

I'd much appreciate a Windows 10 user trying this please, as it has me stumped.

 

The following simple macro on my new PC runs glacially slowly. Takes nearly 10 seconds.

Mouse Move: 10, 600 Relative to Screen // Move to arbitrary position near left of screen
Repeat Start (Repeat 500 times)
  Mouse Move: 1, 0 Relative to Last Position
  // With the Get Pixel Colour command added, the mouse moves glacially slowly.
  Get Pixel Color from Beneath the Mouse into %N[1]%
  Delay: 1 milliseconds
End Repeat

Without the Get Pixel Color, it's over in a flash as you'd expect.

 

Quite a lot of my macros use this command, so it's potentially serious for me.

 

EDIT: Hmm, I added a file to my post but it didn't show up. Trying again.

 

 

--

Terry, East Grinstead, UK

 

TestSlowCommand.mex

Link to comment
Share on other sites

Another approach is to check the pixel colour at (x, y) rather than under the mouse pointer:

// Check every pixel along a horizontal path from (100, 200) to (400, 200)
//
Variable Set Integer %x% to 100
Variable Set Integer %y% to 200
Repeat Start (Repeat 300 times)
  Get Pixel Color at (%x%, %y%) Relative to Current Window into %PixelColour%
  If Variable %PixelColour% Equals "123456"
    Text Box Display: Pixel colour found at %x%, %y% 
    Macro Stop
  Else
    Variable Modify Integer %x%: Increment
  End If
End Repeat
Text Box Display: Pixel colour was not found

This method runs faster, although I haven't tried it in Windows 10. While debugging these scripts, I usually include a mouse move command in the loop just to ensure the math is right, and then comment it out or delete it after the macro is working.

Link to comment
Share on other sites

Cory: If your question was to me ... "Takes nearly 10 seconds." And on my old PC..."it's over in a flash as you'd expect." Say ½ sec.

 

I've sent a possible bug report.

 

--------------------

 

Alan: Thanks, I agree, that's usually my preferred method too. But it's not so convenient in this particular macro because on detecting the specified colour (a vertical border) the mouse cursor drags it to a required position. I'll try re-writing it though, and report back.

 

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Prompt response from Insight:

 

"We are seeing the same thing - about 8 - 9 seconds. This also occurs in Windows 7. We think this is a change in the behavior of Windows. We don't have any type of fix for this. Sorry."

 

Disappointing. I wonder if there are other commands that have suffered in Windows 10? I'm only now beginning to edit and test hundred of macros written under XP.

 

Terry, East Grinstead, UK

Link to comment
Share on other sites

Prompt response from Insight:

 

"We are seeing the same thing - about 8 - 9 seconds. This also occurs in Windows 7. We think this is a change in the behavior of Windows. We don't have any type of fix for this. Sorry."

I use ME3 with Windows 7.

I routinely set Mouse Speed to 30ms in most macros -- seems to work well in most situations. With that setting, the test macro takes 9 or 10 seconds, like others are seeing.

With Mouse Speed 0ms, the macro runs for half a second.

If I eliminate the "Delay 1 Milliseconds" command inside the loop, execution is almost instantaneous.

Including the Get Pixel Color, or removing it, has no noticeable effect on timing.

 

Mouse Speed: 0 Milliseconds

Mouse Move Screen 10, 600

Repeat Start (Repeat 500 times)

Mouse Move Position 1, 0

Get Pixel: Under Mouse into %N1%

Delay 1 Milliseconds (so what is this for, anyhow?)

Repeat End

Link to comment
Share on other sites

I just did some quick comparisons in the various compatibility modes and the sluggishness starts from Win7 onward to Win10.

 

I understand that these are compatibility modes and not the full kernel version of the OS, so it may be different in versions prior to Win10.

 

I also agree the line rberq mentions, seems to be redundant here and does slow macro down.

 

Interesting, if not a bit frustrating, as I don't particularly wish to run the product in compatibility mode.

Link to comment
Share on other sites

Yes, I should really have removed that delay from my test macro. (Although it can only alter the duration by about half a second.)

 

I usually include it in macros that look for a cursor change, which fail if the cursor moves too quickly.

 

Terry, East Grinstead, UK

Link to comment
Share on other sites

  • 2 weeks later...

I set up a similar pixel color scan for my wife's older Windows Vista machine, and the scan was painfully slow because the machine itself is a lot slower. But I found that incrementing mouse position 6 pixels each time though the loop, instead of 1, was adequate to find the button I was scanning for, and SURPRISE :o made the search 6 times faster.

Link to comment
Share on other sites

I asked in the AutoHotkey forum whether AHK scripts were also slower and the answer appears to be Yes. I was pointed to this explanation:

"PixelGetColor, PixelSearch and ImageSearch are all slower when desktop composition is enabled. Desktop composition can be disabled on Windows 7 (i.e. by using the classic theme instead of Aero). It cannot be disabled on Windows 10."

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

That's bad news. :( I chose the Classic theme in XP, Vista, and Win 7. I find Aero themes harder to read because of suboptimal colour contrasts. And animated effects bore me; the novelty wears off quickly.

 

Microsoft software products are looking more and more cartoonish! :blink:

Link to comment
Share on other sites

I agree. I don't mind having a pretty look for those who are into it. But there are very few things that make Windows easier to use or more efficient. And certainly it only slows down performance and in rare cases causes functional problems, especially with legacy apps. My desktop is like a work truck. I don't need to to be blingy, I need it to function. But it seems MS decided to make 22" polished alloy rims standard equipment and there's no option for the plain, cheap, and effect steel wheels anymore.

Link to comment
Share on other sites

I agree. I don't mind having a pretty look for those who are into it. But there are very few things that make Windows easier to use or more efficient. And certainly it only slows down performance and in rare cases causes functional problems, especially with legacy apps. My desktop is like a work truck. I don't need to to be blingy, I need it to function. But it seems MS decided to make 22" polished alloy rims standard equipment and there's no option for the plain, cheap, and effect steel wheels anymore.

+1

MS saw all those books called Windows for Dummies, and decided to make it dumber. Hiding the file extensions, automatically routing files into "standard" folders like Music, Pictures, Videos, Downloads, and worst of all "Documents" in all their variations, replacing Control Panel icons with vague lists ... Did they really think people were too stupid to organize files into folders, all by themselves? So as Windows has become more reliable it has become more opaque and clumsy to control -- like replacing your sports car's rack-and-pinion steering with some heavy-duty rubber bands hooked to the tie rods. :angry:

 

No Macro Express for Linux??? Rats!

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