Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automate an application using VBScript

Tags:

vbscript

I am new to VB Scripting. I want the VB script to act according to an event of an application. Eg : The VBScript should wait till a popup message appears in an application.

like image 649
Ajith Avatar asked Jul 24 '26 06:07

Ajith


2 Answers

VBScript and Windows Script Host only support primitive GUI automation, like activating windows (the AppActivate method) and sending keystrokes (the SendKeys methods). So I doubt that your task can be accomplished with pure VBScript.

However, there's a free GUI automation tool called AutoIt that should be able to do what you need.

like image 72
Helen Avatar answered Jul 28 '26 05:07

Helen


If all you want is to close a pop-up, this may help you:

Set oShell = CreateObject("WScript.Shell") 

Do 
    bResult = oShell.AppActivate("Title of the dialog box") 
    If bResult = True Then 
        oShell.SendKeys "%N" ' Alt+N, you may send {Esc} or {Enter} if you want
        Exit Do 
    End If 
    WScript.Sleep 500 
Loop 
like image 21
Mike Moe Avatar answered Jul 28 '26 04:07

Mike Moe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!