/build/static/layout/Breadcrumb_cap_w.png

VBScript - Conditional window close

Hi Everyone,

I'd like to create a script to close a window if it pops up. Here is what I presently have, but it's not perfect. I want the window to close if it pops up, I'd prefer not to use the 'sleep; that's presently in the script.

--------------------------------

dim sh
set sh = createobject("wscript.shell")
if sh.appactivate("Microsoft Windows Messenger 5.1 5.1.0700 (English)") then
wscript.sleep 250
sh.sendkeys "%{f4}"
end if
set sh = nothing

---------------------------------

Thanks!

0 Comments   [ + ] Show comments

Answers (3)

Posted by: andler 19 years ago
Orange Belt
0
Hi

I have tried using VBscript for this purpose before, but have found AutoIt much better for doing these tasks.
I will recommend using AutoIt.

Take a look at http://www.autoitscript.com

br
andler
Posted by: Paraleptropy 19 years ago
Yellow Belt
0
Thank you. I've already created this using Winbatch, but the boss said to use vbscript, so I'm stuck with vbscript.
Posted by: Byoung4now 19 years ago
Senior Yellow Belt
0
You can use autoit with Vbscript.
It is much better for sending keystokes to windows.

Why are you trying to close this window? Why is it popping up?
maybe you need to look at why the window pops up and how to stop it before it does.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ