SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Aug 2001
    Location
    A planet far, far away...
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Capture Window Caption in C++Script

    Hello all,

    I've been trawling through the forum for ages and can't find what I'm looking for. I just want to write a small function that captures a window's caption and returns it to the calling function (or a pointer to it). Is this possble in TC7.5? Is it possible in C++Script. Are pointers used in C++Script.
    I've never used TC or C++Script so forgive my ignorance.
    I must say, this is the weirdest C++ I've ever seen [img]/images/graemlins/smile.gif[/img]
    Thanks in advance.
    Jolum

  2. #2
    Senior Member
    Join Date
    Aug 2006
    Posts
    1,920
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Capture Window Caption in C++Script

    Hi,

    [ QUOTE ]
    write a small function that captures a window's caption and returns it

    [/ QUOTE ]
    Something like this:
    <font class="small">Code:</font><hr /><pre>function getCaption()
    {
    var obj = Sys["Process"]("something")["Window"]("something_else");
    return obj["WndCaption"];
    }</pre><hr />

    [ QUOTE ]
    I must say, this is the weirdest C++ I've ever seen

    [/ QUOTE ]
    C++Script is JScript with a modified property/method call notation - by default, it uses the [] operator instead of . to access properties and methods of objects (however, both notations are valid). See the "Writing C++ Scripts" help topic.
    Jared - AQA Support

  3. #3
    Member
    Join Date
    Aug 2001
    Location
    A planet far, far away...
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Capture Window Caption in C++Script

    Thanks for the quick reply Jared.

    Will give that a go.
    Jolum

  4. #4
    Member
    Join Date
    Aug 2001
    Location
    A planet far, far away...
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Capture Window Caption in C++Script

    Hi Jared, can't really get this to work. I'm assuming the code you wrote above:

    function getCaption()
    {
    var obj = Sys["Process"]("something")["Window"]("something_else");
    return obj["WndCaption"];
    }

    Does that assume that I will know what the window's name will be in advance? i.e. Sys["Process"]("Application under test")["Window"]("Window Name");

    The thing is I won't know what the window is called. What I'm trying to do is test where I am in the app before continuing with the script. I thought something like this would work in this case:

    function GetCaption()
    {
    var obj = Sys["Desktop"]["FocusedWindow"]();
    return obj["WndCaption"];

    But when I try to run it that doesn't work either. Also what gives with the Log function? In order to test this I was doing the following

    var p;
    p = GetCaption();
    Log["Message"](p);

    But that returned an empty string. I then set up a watch on 'p' and stepped through the code. That showed that 'p' contained ??????....which brought me here.

    I'm lost. Please help.
    J
    Jolum

  5. #5
    Member
    Join Date
    Aug 2001
    Location
    A planet far, far away...
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Capture Window Caption in C++Script

    Quick update.

    Got this to work:

    function GetCaption()
    {
    var obj = Sys["Desktop"]["ActiveWindow"]();
    return obj["WndCaption"];
    }

    But still confused why I can test against but can't log what the function returns??
    This works:

    var p;
    if p=="A KnownCaption"
    Log["Message"]("OK");
    Else
    Log["Message"]("Not OK");


    But this doesn't:

    p = GetCaption();
    Log["Message"](p);

    Any ideas what I'm doing wrong as I'd like to log what the 'wrong' window's caption was before the script moves on and does something else.
    Jolum

  6. #6
    Senior Member
    Join Date
    Aug 2006
    Posts
    1,920
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Capture Window Caption in C++Script

    Hi,

    I recommend that you check the problematic variable's type - perhaps, it is not a string (see the "aqObject.GetVarType" help topic).
    Jared - AQA Support

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:52 PM.

Copyright BetaSoft Inc.