Results 1 to 8 of 8
  1. #1

    Regular Expressions

    Need to close the opened windows dynamically.

    My script will open all files dynamically one by one from the result page. The opened files may be with the extension of .html, htm, doc, xls, ppt. zip, vcf etc. How do I dynamically identify the opened window to close them using regular expressions?

    The following code is not recognizing the opened window.

    strWinTitle = ".*" & param_name & ".*"
    Set win_handle = Window("text:=" & strWinTitle)
    if win_handle.exist then
    Result = "True"
    Result = "False"
    End if

  2. #2

    Re: Regular Expressions

    you could use hwnd = extern.GetForegroundWindow() in a function or CreationTime in order to do this
    I like what i know and I know what i like

  3. #3

    Re: Regular Expressions

    Thanks for reply.

    I already tried this. But the extern.GetForegroundWindow() will return the window handle only when the newly opened window have focus on it, else it will return wrong window handle. Please suggest me any other way.

  4. #4

    Re: Regular Expressions

    If you use the CreationTime class, you should be able to close each window by session creation time
    I like what i know and I know what i like

  5. #5

    Re: Regular Expressions

    Maxj, Creationtime is only available for browsers and nothing else. You can use it on normal windows.

  6. #6

    Re: Regular Expressions

    Correct. CreationTime will support only the opened browsers. But I need to dynamically identify different windows when it open and also need close them. Any idea?

  7. #7
    Senior Member
    Join Date
    Oct 2003
    Kyiv, Ukraine

    Re: Regular Expressions

    why you can't use SystemUtils object methods? -
    CloseDescendentProcesses, CloseProcessByWndTitle etc.

    strWinTitle = ".*" & param_name & ".*" can recognize as many windows as many opened ones you have, it doesn't describe any window uniquily - therefore i think using regular expressions for that kind of task is not suitable.

  8. #8

    Re: Regular Expressions

    Hi all,
    I solved the issue by using the following code:

    Dim running_app
    Set running_app = Window("Window").WinToolbar("RunningApplications")
    With running_app
    running_app_title = .GetContent()
    app_arr = split(running_app_title, Char(10))
    total_app_cnt = uBound(app_arr)
    if total_app_cnt > 0 then
    for app_cnt = 0 to total_app_cnt
    Win_title = app_arr(app_cnt)
    Set hWindow = Window("text:" & win_title)
    ‘write a condition to check QTP and testing application title before closing
    if hwindow.exist then
    Result = "True"
    Result = "False"
    End if
    End if
    End With

    The above code is working fine for me. Am I on the right track?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:56 PM.

Copyright BetaSoft Inc.