How to detect save as dialog box in IE using Vbscript - 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"

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}"

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.

VB Script to click a button in a website for every 30 seconds with refresh

How to to write a VB Script, which will open a particular url and click a button in that website for every 30 seconds, and also refresh the page if possible.
You help will be appreciated.
I have written the following script:
Set IE = CreateObject("InternetExplorer.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
IE.Navigate "some url"
IE.Visible = True
Document.All("spin").Click()
I have problem with selecting the button to be clicked. Is this the correct script.

How to click on ok on remote machine while starting machine by using vbscript

I am connecting to Remote machine successfully by using below VBScript But the problem is it is stopping at OK button. If once I click on ok Manually then machine is opening.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set cloner = CreateObject("WScript.Shell")
cloner.run"mstsc"
'run remote desktop connection
WScript.Sleep 1000
cloner.SendKeys"DV01234"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"password"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
'cloner.run"cmd"
CAN ANY ONE HELP ME HOW TO CLICK OK BY USING VB SCRIPT ?
If you are using UFT 11.50 (UFT is the new name for QTP) you can use Insight in order to use image based identification to identify the OK button and click on it.

refresh firefox from .bat file/ command

I am attempting to refresh Firefox whenever a bat file is called. I Dont want an extension. I need to know if there is a command that can be used from within a .bat file to reload the current browser or tab.
I know you can use
start firefox as a command but this simply opens a new firefox instance. I need to refresh the current instance.
I was just messing around and came up with this half-working solution that might help a little. Create a file called something like refresh.vbs and paste this in:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate("Google Chrome")
WScript.Sleep 500
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{F5}"
I could only test it with Chrome. The script activates Chrome, sends a tab, and then sends F5 to refresh. It works when I have Chrome up showing one web page, but not when there are multiple web tabs open (because AppActivate activates the Window, but does not give focus to anything).
Maybe it works better with Firefox. There's probably some way to enumerate the tabs in a browser and activate it in vbs, but I don't know it.
If you spawn the browser within the vbs (see WshShell.Run, and the example in the SendKeys documentation), you can get the process number and send messages directly to that Window instead of relying on the app title.
You can invoke the .vbs from within a batch file if you need to:
#echo off
refresh.vbs
On Error Resume Next
Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate "http://www.microsoft.com/technet/scriptcenter"
objExplorer.Visible = 1
Wscript.Sleep 5000
Set objDoc = objExplorer.Document
Do While True
Wscript.Sleep 30000
objDoc.Location.Reload(True)
If Err <> 0 Then
Wscript.Quit
End If
Loop

Resources