In my application i need my Excel file to get maximize whether in the foreground or background.I have using batch file command "START "file_window_title" /MAX" But it maximizes the Command prompt window but not the file whose title is mentioned in the command?
Asked
Active
Viewed 471 times
-2
-
possible duplicate: http://stackoverflow.com/questions/14760518/how-can-i-maximize-a-specific-window-through-cmdwindows – cdMinix Jul 09 '14 at 11:54
1 Answers
0
This is a hybrid batch/javascript file (save as .cmd
) that will try to maximize a window given its title. You can call it as
maximize.cmd "This is the window title"
If a window exists that match this title, sendkeys
method is used to send Alt+space+x to use the window menu to maximize it.
@if (@This==@IsBatch) @then
@echo off
rem **** batch zone *********************************************************
rem call javascript part of batch file
cscript //nologo //e:Javascript "%~f0" /title:"%~1"
rem End of batch area. Ensure batch ends execution before reaching
rem javascript zone
exit /b
@end
// **** Javascript zone *****************************************************
// Instantiate shell component
var shell = new ActiveXObject('WScript.Shell');
// Activate window
if (shell.AppActivate(WScript.Arguments.Named.Item('title'))){
// Maximize window
shell.SendKeys('% x');
};
// Exit
WScript.Quit();

MC ND
- 69,615
- 8
- 84
- 126