Link to home
Start Free TrialLog in
Avatar of Pretzel_Jesus
Pretzel_Jesus

asked on

Minimize Specific Window Using VBScript

I want a VBScript that checks all currently opens windows and if a specific window exists (by title) I want the script to minimize it.
ASKER CERTIFIED SOLUTION
Avatar of Tompa99
Tompa99
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robberbaron (robr)
Tompa is correct.

but you need to remember that AppActivate need the FULL title, or a Prefix or suffix of it.
this can have unexpected consequences

WSH help....
"In determining which application to activate, the specified title is compared  to the title string of each running application. If no exact match exists, any  application whose title string begins with title is activated. If an  application still cannot be found, any application whose title string ends with  title is activated. If more than one instance of the application named by  title exists, one instance is arbitrarily activated."

eg if you open a new notepad application. empty. then run the following scrip

set shell = createobject("wscript.shell")
 
'these return true ie -1'
y = "Notepad"
x = shell.AppActivate (y)
WScript.Echo y,x
 
y = "Untitled - Notepad"
x = shell.AppActivate (y)
WScript.Echo y,x
 
y = "Unti"
x = shell.AppActivate (y)
WScript.Echo y,x
 
y = "pad"
x = shell.AppActivate (y)
WScript.Echo y,x
 
y = "epad"
x = shell.AppActivate (y)
WScript.Echo y,x
 
'returns false 0'
y = "note"
x = shell.AppActivate (y)
WScript.Echo y,x
 
y = "d - N"
x = shell.AppActivate (y)
WScript.Echo y,x
 

Open in new window