开发者

How do I automate a right click in VBScript?

I want to automate simulation of a right click to open the context menu. Once the menu is open, select the selected action/shortcut available.

I know how to open:

WshShell.SendKeys("+{F10}");

Or using the AutoIt automation language (BASIC like):

  ;--on right click event
    MouseClick("right")
    $count = 1
    Do
        Send("{DOWN}")
        $count = $count + 1  

    Until $count > 7
    Send("{ENTER}")
    ;---select shortcut
    WinWaitActive("xxxxk")

    ;----doing execution from the 3rd program
    ControlSend("xxxxx",  "", "Edit2", "123ABC")
    Sleep(500)
    ControlSend("xxx开发者_如何学编程xx",  "", "Edit3", "123ABC")
    Sleep(500)
    Send("{ENTER}")
    Sleep(500)

    WinClose("xxxxx")
    WinWaitActive("xxxxx", "Close")
    Send("{ENTER}")

Can I have something like this in VBScript? Too messy, I think.


your answer is in your question

WshShell.SendKeys("+{F10}");

once the right click menu is open send another key 's' (in most cases 's' is used to select/select all)

shell.Sendkeys  "s"

and you're done :)

here goes the complete code

shell.Sendkeys  ("+{F10}")
shell.Sendkeys  "s"

the above code should work in VBScript right click automation,

i'd also like to mention that Right-Click in a title bar is equivalent to ALT+SPACE, so if you want to right click on the title bar by vbscript i'll advice you to send ALT+SPACE instead

Source: http://msdn.microsoft.com/en-us/library/8c6yea83%28VS.85%29.aspx


Right click on what?

If you are talking about files/folders (in Windows Explorer), you can do it with shell automation: DoIt or InvokeVerb

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜