Jump to content
Macro Express Forums

How to test a selection is active ?


Recommended Posts

Hi, need your help !

 

My macro is designed to help me colour layers in a graphic program (Manga Studio)

The tool palette is similar to photoshop with magic wand, eyedropper and fill tools. The macro selects the magic wand tool for me, I move to the image and select an area, then it moves to the colour palette, I select a colour and it sends the mouse back to my selection and fills it with the colour. If the area is a small one everything works fine, and I have my fill completed for me.

However, If the area is a large one it fails. I am assuming the mouse is moving to the eyedropper before the selection has had time to become active. Is there any way to test that the selection process is complete, before the macro moves on ...

Why not just put a delay in?

Delays don't work too well, as for some reason the selection can take several seconds to complete, and such a long delay would be quite annoying for small repetitive selected areas.

Would really appreciate some ideas...

 

Link to comment
Share on other sites

Tough problem. Watch carefully while waiting for the selection to become active, and look for (1) cursor pointer changes, and/or (2) colour changes somewhere in the user interface. If you spot something that is updating, you may be able to infer when the selection is ready by monitoring, for (1), changes to the mouse pointer shape, or for (2), changes in the colour of a particular pixel.

 

Something like this, in pseudo code:

 

// Monitor the shape of the mouse pointer until it is not an hourglass

Mouse Mouse to 100, 100 relative to the window

Repeat 100 times

If Mouse Pointer = hourglass

Wait 100 ms

Else

// The wait is over, so assume selection is ready.

// Perform the action.

Repeat Break

End if

Repeat End

 

// Monitor a pixel until it changes to red
Mouse Mouse to 200, 200 relative to the window

Repeat 100 times

If Pixel Colour is NOT Red

Wait 100 ms

Else

// The pixel is red, so assume selection is ready.

// Perform the action.

Repeat Break

End if

Repeat End

Link to comment
Share on other sites

Alan, thank you for your reply. You have given me the solution. When I click the mouse in the area, and when the program is working out the dimensions and extent of the selected area, there is a spinning "donut" like icon with colours that I can test for at a specific number of pixels away. Will post my code here when I work it out. Thanks again.

Link to comment
Share on other sites

Hi again .. was testing the method above, and moved the mouse pointer 10 pixels in the x direction, paused one second, then returned the pointer -10 pixels to bring it back to its original position. This I did to test if the donut icon moved with it...

 

Anyway, this has solved the problem !! Maybe my initial presumptions were wrong, but I'm happy now ..... thanks!

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