Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Wscript/cscript help  (Read 5472 times)

0 Members and 1 Guest are viewing this topic.

kamak

    Topic Starter


    Rookie

    Wscript/cscript help
    « on: July 25, 2008, 08:13:35 AM »
    Hi all!

    I have a small question:

    How would i go about automating mouse clicks sing a .vbs file?

    I know that the following saves a notepad file, but how can i use the same language and method to make the mouse click?

    Code: [Select]
    set WshShell = WScript.CreateObject("WScript.Shell")
    WScript.Sleep 10
    WshShell.AppActivate "wordola.txt"
    WScript.Sleep 10
    WshShell.SendKeys "%"
    WScript.Sleep 0.1
    WshShell.SendKeys "{DOWN}"
    WScript.Sleep 0.1
    WshShell.SendKeys "{DOWN}"
    WScript.Sleep 0.1
    WshShell.SendKeys "{DOWN}"
    WScript.Sleep 0.1
    WshShell.SendKeys "~"
    WScript.Sleep 10

    Thanks in Advance,

    kamak

    diablo416



      Hopeful
      Re: Wscript/cscript help
      « Reply #1 on: July 25, 2008, 08:25:18 AM »

      kamak

        Topic Starter


        Rookie

        Re: Wscript/cscript help
        « Reply #2 on: July 25, 2008, 08:43:43 AM »
        you can read more here http://msdn.microsoft.com/en-us/library/aa922603.aspx

        How would i implement that into a .vbs file like my example above?

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: Wscript/cscript help
        « Reply #3 on: July 25, 2008, 12:18:30 PM »
        Quote
        How would i implement that into a .vbs file like my example above?

        You probably wouldn't unless you've gone mobile!

        Consider which control has focus; then consider how many times you have to hit the tab key to give the control in question focus. Once the the control has focus, send the enter key (same as a mouse click in this context).

        Microsoft might have had a great editor if they'd made notepad scriptable. Instead only the clunky sendkeys method seems to work. You can make menu choices with sendkeys by using alt+underline letter (atl-f for file or alt+e for edit etc) to grab the menu, or use the menu shortcuts to do things like save (ctl-s) or paste (ctl-v), etc.

        Are you sure the WshShell.AppActivate "wordola.txt" is correct? That does not appear to be the window title for notepad.

         8)
        « Last Edit: July 25, 2008, 01:20:07 PM by Sidewinder »
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein