Need to open chrome browser and send inputs using VBScript [duplicate] - vbscript

This question already has answers here:
How to programmatically open a website and click buttons
(2 answers)
Chrome: Possible to script like InternetExplorer.Application in VBScript?
(2 answers)
Closed 13 days ago.
Trying to open chrome and send input to some text fields using vbscript. Major need is to send input to the webpage. I see that we can do it using IE but I need it to be done through chrome or edge. I also need to know if this is possible without using selenium basic as I do not want to use it.
I'm very new to vbscript so any help would be appreciated.
The code I have worked on so far, able to open chrome and webpage.
sub chromeTest()
Dim iURL
Dim objShell
iURL = "MySample"
set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "chrome.exe", iURL, "", "", 1
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "Hello"
end sub

Related

Open as active window

I am trying to create a very simple vbscript that opens a browser to a specific webpage then refreshes. The problem I am having is trying to make the browser the active window, I have searched various sites and tried various forms of appactivate but with no success. I normally don't work with VBS so I might be missing something super obvious, Please see below for what I have so far
set wshShell = WScript.CreateObject("wscript.shell")
wshShell.Run("http://www.example.com")
wshell.senkeys "{F5}"
I would be very grateful for any assistance.
You can use "AppActivate" and you need to wait for the response:
set wshShell = WScript.CreateObject("wscript.shell")
wshShell.Run("http://www.example.com")
Wscript.Sleep 1000
wshShell.AppActivate "Firefox" 'here put the name of the window
Wscript.Sleep 1000
wshell.senkeys "{F5}"

Create a VB script to send the keys to open up a program with specific settings

I am trying to create a VB script to send the keys to open up a program/application with specific settings. So, after the application has been started, choosing those very specific settings would involve pressing 2 buttons inside the application UI (1st button to choose specific set of options, and 2nd button to save those options).
I will then create a batch file to call the mentioned VB script on boot.
So far, I got this:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "^%1"
I've searched and searched, but couldn't figure out how to be able choose/save options once the app has been started, if it's even possible?
Thank you in advance for helping out!
Disclaimer: I am not a technical person, so forgive me if noob question :)
Here's a script to start an application (notepad), then send some keystrokes to it:
'VBScript Example
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\windows\notepad.exe"
' add delay here
WshShell.AppActivate "Notepad"
WshShell.SendKeys "Hello World!"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "abc"
WshShell.SendKeys "{CAPSLOCK}"
WshShell.SendKeys "def"
Perhaps this can be adapted to your needs?
The WshShell.AppActivate command is used to bring the program (with the specified window title) to the foreground.
You might want to add a delay to allow the program time to start before sending the keystrokes. This can be done by adding a sleep() call just after Wshell.Run:
' Sleep for 5 seconds (5000 msec)
WScript.Sleep(5000)
Also, here's a list of key-codes that you can use.

how to automate click event and combobox selection of any windows application using vb scripts

I am new to VBScript, I need to automate click events to some buttons using its class or id ctrl attribute and select specific option from combo box list. I already have the control attributes like class name or id using which I have to automate different events to the windows applications using vb script.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
now I have to do addition of 5 and 6, I have respective ids as num5Button(5), plusButton(+), num6Button(6) and equalButton(=). I need perform click operation for this button. How should I do this?
Since you are automating Calculator, you can use SendKeys to automate the math functions. Sample code is
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 500
WshShell.AppActivate "Calculator"
WshShell.SendKeys "5{+}"
WScript.Sleep 500
WshShell.SendKeys "6"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
I would recommend using something like AutoIt for automating basic Window GUI operations.

How do I display a message box once I quit wscript

I have been trying to learn Web Scraping using VBScript since VBA for Outlook does not work like VBA for Excel
So I am trying to display a message box to see whether or not my script is getting to specific points. I can display the first message box but not the second one. I understand that it is due to the line wscript.quit but I need that line otherwise I can't open IE.
Msgbox ("hello"),0,("title")
set Shell = createobject("wscript.shell")
Shell.Run "google.ca"
wscript.quit
DIM IE
Set IE = CreateObject("IExplorer.exe")
Msgbox ("hello"),0,("title")
All help is appreciated, Thanks.

How to detect save as dialog box in IE using Vbscript

I am writing a simple vbscript as shown below to Click "Save" on the save dialog box that opens whenever we click on a download in IE but so far it's not working
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.AppActivate ("Internet Explorer")
WScript.Sleep 10000
WshShell.SendKeys "%S"

Resources