Forum Discussion

Oferv's avatar
Oferv
Super Contributor
12 years ago

is there a way to differentiate between text to picture(gif,bmp,jpg,etc)?

Hi,



I was wondering if there's a way to differentiate between text to picture(gif,bmp,jpg,etc)?

can TC has the abilities to do that?and if yes how?

i'm using Sys["Clipboard"]  to catch the text on the screen and when a picture display i want Tc to ignore it



Thanks

6 Replies

  • Hello Ofer,

    Reading from the documentation http://support.smartbear.com/viewarticle/11044/

    When Sys.Clipboard holds an image, the property returns a Picture object. You can use the IsObject() function to see if the clipboard returns an object.

    eg.

    If IsObject(Sys.Clipboard) Then

      Log.Message("A picture is held in the clipboard")

    Else

      Log.Message("A string is held in the clipboard")

    End if

    Cheers,

    Jackson
  • Oferv's avatar
    Oferv
    Super Contributor
    Hi Jackson,



    that doesn't work,it popup an error says 'object expected'



    thanks,
  • Hello Ofer,

    I'm so use to VBScript/JScript I was coding in that. I see you're probably using C# script or the like. Did some reading and looks like you can use GetVarType() to determine the variant type.

    http://support.smartbear.com/viewarticle/12102/ 

    eg.

    function Test()

    {

      // Storing and getting an image 

      //Sys["Clipboard"] = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 0)["Picture"]();

      // Storing and getting text 

      Sys["Clipboard"] = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 0)["WndCaption"];



      TypeID = GetVarType(Sys["Clipboard"]);

      Log["Message"]("Type: " + TypeID);

      if (TypeID == varOleStr) 

      {

        Log.Message("A string is held in the clipboard"); 

      }

      else

      {

        Log.Message("A picture is held in the clipboard"); 

      }

    }

    Cheers,

    Jackson
  • Oferv's avatar
    Oferv
    Super Contributor
    Hi Jackson,



    well, i think that the problem is that the picture i took for the specific example is holding one character in it and this character is 'space' and therefore TC is recognize it as a text.just an assumption.



    what do you think?



    Thanks 
  • Hello,

    Yes that's a possibility and if it is, then running that against the code above will give you log message "A string is held in the clipboard".



    Cheers,

    Jackson