Pixel color change help needed please

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Pixel color change help needed please

Post by Jaylee » Thu Sep 13, 2007 6:07 am

Hi,

Using 9.0.046 on XP SP2.

Could I please get some coding help with pixel colour?

I am using MS to emulate entering data into specific screens in a SAP application.

In some screens when I hit "Enter", SAP provides a warning/information panel at the bottom of the screen. This message lights up yellow (pixel colour 14931127 and requires further "Enter" button pushes until it finally goes green (pixel colour 1680973). The green indicates the screen can now be saved.

The number of "Enters" can differ and, even after the green and "Save" is applied, further yellows can appear and require more "Entering".

What I'm trying to do is to say:
Press ENTER
If (at screen position) 620,721 is 14931127 (yellow)
Press ENTER (again)
or If (at screen position) 620,721 is 1680973 (green)
Press CTRL
Send>s

Could someone please help me with the code I need to make this work?

I have tried:

Code: Select all

Let>PC=1680973
SetFocus>Copy Actions
Press ENTER
WaitPixelColor>1680973,620,721,1
If>PC=1680973,CChange1,CChange2
EndIf
Label>CChange1
Press CTRL
Send>s
RELEASE CTRL
Label>CChange2
Press ENTER
but I really have no idea what I'm doing here and I end up with a couple of "Enters" but never get to a green and "Save".

I would be really grateful for assistance as I struggle with code at the best of times.

TIA.

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 13, 2007 6:55 am

Hi,

Well, you would need a loop. Inside the loop you check the pixel color. If it's yellow you press enter and loop back again. The loop loops until the pixel color is green. So you can do it like this:

Code: Select all

Let>yellow=14931127
Let>green=1680973

Let>color=yellow
Repeat>color
  GetPixelColor>620,721,color
  If>color=yellow
    Press Enter
  Endif
Until>color=green
Although I can't help thinking there might be a more direct way to wait for your SAP action to complete - maybe using WaitScreenImage or FindImagePos ?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 13, 2007 6:56 am

Using 9.0.046
Just wondering why you're using 9.0.046? The latest version is 9.1.04 and it's a free update for anyone with 9.x.

Update history at http://www.mjtnet.com/mswhatsnew.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Thu Sep 13, 2007 7:16 am

Hi Marcus,

Thank you for the code assistance, I will try it right now.

As for the version ... I am aware of the update and have downloaded it. I just simply haven't got around to installing. I may never get around to it as my job has just been made redundant and I exit in 3 weeks unless there is a major change of heart (but I think not) ... :?

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Thu Sep 13, 2007 9:07 am

Ooookaaay,

Not having a lot of luck with the pixel colour change code as I am finding other obstacles the SAP application is throwing at me.

So, I've given in and installed 9.1.04 to give me WaitScreenImage with a timeout function. When SAP does the colour change thing, it also provides different icons depending on the colour change. I have saved these as bitmaps to the C drive. I have successfully used the WaitScreenImage function before but that was when I was certain the same image would always appear. Now I have a number of image choices so I can search for what is expected and use labels to make logic decisions.

But I'm stuck again as I am uncertain how to use the syntax for the timeout feature.

Could you, please, provide an example?

Many thanks.

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 13, 2007 9:12 am

//set WaitScreenImage timeout to 5 seconds
Let>WSI_TIMEOUT=5

WaitScreenImage>someimage.bmp

If time out occurs WSI_TIMEDOUT will be TRUE.

Be sure to capture the bitmaps with Macro Scheduler's capture tool - which you will find on the WaitScreenImage code builder dialog and also in the editor under Tools/Image Capture Tool.

If you use a different means of capturing the images you may end up with images of a different color depth and not comparing like with like. Always use Macro Scheduler's image capture tool.

Sorry to hear about your job situation.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts