Capture the text color from terminal session

I am using “IBM Personal Communications , iSeries Access for Windows” terminal and uiPath activity “Terminal Session” to connect with “IBM PC terminal”. I can do the data entry, but there is one business scenario where I need to get the text color and basis of that color (Green) I have to add business condition. Can anyone tell me how to capture the text color from terminal session of specific line ?

In my case there is white, Green and black colors are present in terminal window.
Below is the text screenshot;

image

1 Like

Have you tried importing the namespace System.Drawing and using the Bitmap.GetPixel Method?

You can read more about it here : https://docs.microsoft.com/en-us/dotnet/api/system.drawing.bitmap.getpixel?view=netframework-4.7.2

@AlexViz For BItmap a image file path is specified. In my case there is no image, I am using IBM PC terminal session.

How can I implement your suggested way ?

I am trying to do using https://forum.uipath.com/t/extract-pixel-coordinates-of-a-rectangle/72126/2 but not able to find the pixel position , e.g as see in above screenshot I have to get the green color pixel position(left,top,right,bottom) U letter of “User” word.

How can I get the green color pixel position of letter “U” ?

@Bhushan : Please find my solution using color detector activity GetGreen.xaml (8.7 KB)

I am using Get Position activity to get the position of image on this page then I am using find OCR text to get the text location of User on that image.
I added the position of image with position of user word and supplied it as an input to color detector activity.

1 Like

@palindrome

I have already added color detector package but still getting error. Not able to see your code

Oh I was using different version.
Here is the updated file: GetGreen.xaml (8.7 KB)

@palindrome

Found this error in code

Please check:

@palindrome

I am working on following scenario,

  1. I am using IBM WINS terminal not the image. There is a scenario where multiple times for a specific text (e.g. google) is in “Green or white” color in multiple WINS pages. So to compare the color robot have move and compare on multiple WINS pages (by pressing down key).
    a) As you have guide me one way by using image, if need to use the image then for every page I have to capture the screenshot and process as you suggested.
    b) How can I specify Attach Browser activity selector or the path of the image ? How can I specify “Get Position IMG” activity selector ? How can I specify “Find OCR Text IMG” activity selector ?
  2. WINS screen can be move or display at any position when it’s execution started, so how can I get the exact X and Y position for specific text (X and Y position must be present inside the WINS window)?

Please find below WINS app window screenshot;

Hi @Bhushan,

You don’t need to take screenshot. These activities can be directly applied to terminal window.
Instead of Attach browser use attach window activity(ie attach to terminal window).
This is what I mean:(Please ignore error in image)

I have tried to visualize the output of above activities here:

As both the positions are extracted dynamically, so I am sure the output will be correct even if the WINS screen is moved.

Please note this will only work when the Window is activited… If window is hidden or minimized it will provide incorrect output or exception.

@palindrome Please see below screenshot this is the scenario, as shown point 1 and 2 both having the same data , but the difference between them is “White and Green” color. On the basis of color condition only I have to choose the record and process ahead.

  1. I have done a sample code as you have suggested but not getting the required result.
  2. While testing I entered different text in “Find OCR text” activity to get the color from WINS screen, but not getting the exact color as the text is having.
  3. “Get Position” activity lies under “UI Automation”, not under “Terminals”. So does it helpful in my scenario or not ? I am not sure.
  4. As my text position is dynamic so I have used only selectors in code activity not using “indicate on screen” option to capture the informative screenshot.

Please find the attached below code file :

SampleDemo.xaml (13.9 KB)

@AlexViz Yes, but how can I get the coordinates of green color text ? Please see the blow communication.

  1. I have done a sample code as you have suggested but not getting the required result.
  • Like i said before you ll need to get position of application and add position of text, then only you can find the correct location of word on screen.
  1. While testing I entered different text in “Find OCR text” activity to get the color from WINS screen, but not getting the exact color as the text is having.
  • Find OCR Text will provide the position of the text with respective to the application window.
  • Get Position will provide the position of the window with respective to screen
  • if you add you ll get the position of word with respective to screen. This is what we want to achieve in order to get the color.
  1. “Get Position” activity lies under “UI Automation”, not under “Terminals”. So does it helpful in my scenario or not ? I am not sure.
  • yes this lies under UI Automation. If terminal is on screen then you can use any kind of UI automation. Color Detector activity takes the X and Y coordinate of pixel on screen and provides it color.
  1. As my text position is dynamic so I have used only selectors in code activity not using “indicate on screen” option to capture the informative screenshot.
  • This does not matter. only the selectors are useful in identifying any application.

Hi,

I am able to get the background color of the text, but not the text color actually.

Eg:- I have text “India” in yellow, on the background color “Red”.
After doing the same code for this scenario, I am getting the color of text India as “Indian Red”
inspite of some shade of Yellow.

Can anyone help me with the same.

Thanks in advance. :slight_smile: