Hi,
I programmed a little bat file that opens two folders on the desktop. Is it possible to automatically align the folders on the screen ? Like dragging it on the side with the mouse or pressen Windows+Arrow Key ?
Code is:
explorer "D:\mypath"
IF exist F:\mypath explorer "F:\mypath"
Regards
Align Windows via bat
Moderator: DosItHelp
Re: Align Windows via bat
Provided there're just 2 above windows open on the desktop, save required Align.vbs script to a file, and launch it from a batch:
Code: Select all
cscript "K:\Files\Align.vbs"
Re: Align Windows via bat
As sambul35 already insinuated you would need another language. Of course you could also write it in a hybrid script.
*.bat
Regards
aGerman
*.bat
Code: Select all
@if (@a)==(@b) @end /* Batch portion:
@echo off &setlocal
:: run this script as JScript code and pass the folders that should be opened and tiled vertically
cscript //nologo /e:jscript "%~fs0" "C:\Windows" "C:\Program Files"
exit /b
JScript portion: */
var objWShell = new ActiveXObject('Wscript.Shell');
var objShellApp = new ActiveXObject('Shell.Application');
var objFSO = new ActiveXObject('Scripting.FileSystemObject');
// minimize all open windows
objShellApp.MinimizeAll();
// iterate over the passed arguments
for (var i = 0; i < WScript.Arguments.Count(); ++i){
// if the passed folder exists
if (objFSO.FolderExists(WScript.Arguments.Item(i))){
// suspend the execution of the script for a few milliseconds in order to make sure the former operation was triggered
WScript.Sleep(150);
// open the folder in a new explorer window
objWShell.Run('explorer.exe /n,"' + WScript.Arguments.Item(i) + '"');
}
}
// suspend the execution of the script for 2 seconds in order to give the windows a chance to open
WScript.Sleep(2000);
// tile all of the (not minimized) windows vertically
objShellApp.TileVertically();
Regards
aGerman
Re: Align Windows via bat
Will it tile only the Explorer windows, even if other program windows are open? My above suggestion can't do that.
I'd rather use free WDE instead of a batch for this.
![Wink :wink:](./images/smilies/icon_wink.gif)
Re: Align Windows via bat
The TileVertically() method tiles all of the windows on the desktop. For that reason I minimize already opened windows (including the console window) before I open the new Explorer windows. Thus, only the Explorer windows are on the desktop...
Regards
aGerman
Regards
aGerman