Results 1 to 5 of 5

Thread: Wscript.Shell

  1. #1


    I am trying to use the shell scripting to activate and later pass ALT F key to a notepad.But in spite my all brainstorm QTP is Clicking its own File menu rather then that of the notepad.

    Please suggest some solutions.

    Set WshShell=CreateObject("Wscript.Shell")

    WshShell.SendKeys "%F"
    wait 4.

    WshShell.SendKeys "{DOWN}"
    WshShell.SendKeys "{DOWN}"
    WshShell.SendKeys "{DOWN}"
    Saurabh Verma
    Test Automation Engineer

  2. #2

    Re: Wscript.Shell

    Hi Saurabh,
    i tried your same script(without changing single character) in my PC , its works fine for me. exactly its clicking file menu of notepad. if u r having problem then try ,instead of using "Window("Notepad").Click" try with "Window("Notepad").Activate",if u face same difficulty let me know which QTP version you are using?.

  3. #3

    Re: Wscript.Shell


    I used the Activate method as well but no luck.I am using QTP11 on my machine.
    Saurabh Verma
    Test Automation Engineer

  4. #4

    Re: Wscript.Shell

    Hi Sourabh,
    Try below code.
    <font class="small">Code:</font><hr /><pre> Set fso=CreateObject("WScript.Shell")
    fso.AppActivate("abc.txt") ' Mentioned name of your notepad file

    fso.SendKeys "%F"
    fso.SendKeys "{DOWN}"
    fso.SendKeys "{DOWN}"
    fso.SendKeys "{DOWN}"
    </pre><hr />
    I think you can use earlier approach by defining the Notepad object in OR or using DP. But I have not tried due to problem in my QTP license.
    Mrinal Nandi

    Follow LinkedIn
    Automation Blog

  5. #5

    Re: Wscript.Shell

    Hi Mrinal,

    For me it is not working.This Code is opening the file menu of the QTP itself.
    Saurabh Verma
    Test Automation Engineer



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 07:19 PM.

Copyright BetaSoft Inc.