3

A customer has a 6-screen setup for each workstation and would like various pages of a web app to be opened automatically in each of the screens on startup or invoking a shortcut. (The target web browser is likely to be Chrome).

I wondered whether it would be possible to use Javascript window.open to do this but one possible snag is the customer may wish to have tabbed browsing with popup blocker turned on. (OK, these could be overridden but such config is currently out of our control...)

So the question is: Could a script (e.g. batch file) be written to open multiple instances of the browser at specified coordinates within the 6 screens (each pointing to different URLs)?

[This is basically the same question as https://askubuntu.com/questions/68354/is-there-any-way-to-specify-which-workspace-and-or-window-to-launch-a-program-in but for Windows instead of Ubuntu.]

3
  • @fixer1234 OK have copied the text I think is relevant into the answer below. May 19, 2015 at 7:26
  • @fixer1234: Cleaned.
    – Karan
    May 19, 2015 at 16:24
  • 1
    The proposed duplicate doesn't have good answers but this question does. I've voted to make the other question a duplicate of this one.
    – fixer1234
    May 19, 2015 at 16:29

2 Answers 2

1

Just found this:

https://stackoverflow.com/questions/10392620#20466454

Not exactly what I wanted as it relies on 3rd party tools and quite a complex batch script but it's the best I've got so far...

Edit: As requested by fixer1234, the relevant part of the linked answer is copied below.


This demo batch file will open two Explorer windows side-by-side and centered on the screen at the other (non-primary) monitor of a two-monitor desktop. Read the description in the batch file.

Note: For this demo, I am assuming the left monitor is Monitor-1 (the primary active monitor, containing the taskbar) and right monitor is Monitor-2 (the non-primary active monitor). If your setup is different, then tweak the script.

Tools used:
1. MonitorInfoView by Nir Sofer (41 KB) ..............homepage
2. MultiMonitorTool by Nir Sofer (102 KB) ...........homepage
3. NirCmd by Nir Sofer (43 KB) ...............................homepage
4. A batch file (6 KB) ...............................................see below

Gather all four files into a directory.
This is the batch file, ready to run on any Windows system (run it for an instant demo):

@echo off
REM ----- GIVE THIS CONSOLE WINDOW TITLE A UNIQUE STRING ID
title OPEN-2-EXPLORER-WINDOWS-SIDE-BY-SIDE-AND-CENTERED-ON-SCREEN-AT-MONITOR-2-OF-A-MULTI-MONITOR-DESKTOP___20140101024519
pushd %~dp0

REM ----- HIDE THIS CONSOLE WINDOW (HOOKS THE WINDOW TITLE)
nircmd.exe win hide ititle "OPEN-2-EXPLORER-WINDOWS-SIDE-BY-SIDE-AND-CENTERED-ON-SCREEN-AT-MONITOR-2-OF-A-MULTI-MONITOR-DESKTOP___20140101024519"

REM ********************** DESCRIPTION ************************************
REM ** This script opens one or more windows with specified screen properties
REM ** at a chosen monitor of a multi-monitor desktop. The "X/Y position" and
REM ** "W/H size" of the windows are auto-set by this script and the monitor
REM ** resolutions are auto-calculated to suit. 
REM ** 'MonitorInfoView.exe' is the helper tool used to isolate the resolution
REM ** info of the primary monitor (containing the taskbar).
REM ** 'MultiMonitorTool.exe' is the helper tool used to capture the 
REM ** resolution info of all monitors and for isolating the resolution info
REM ** of the other (non-primary) monitor.
REM ** 'nircmd.exe' is the tool performing all the display trickery.
REM **
REM ** To tweak this script, go to the code section named:
REM ** >>>>> USER INPUT/PREFERENCES ARE ALL SET HERE <<<<<
REM ***********************************************************************

REM ----- CLEAR ANY PREVIOUS JOB OUTPUTS IF THEY EXIST
if exist ~TMP.TXT type NUL > ~TMP.TXT
if exist ~TMP2.TXT type NUL > ~TMP2.TXT

REM ----- OUTPUT THE PRIMARY MONITOR (MONITOR-1) INFORMATION TO A TEXT FILE
MonitorInfoView.exe /hideinactivemonitors 1 /stext ~TMP.TXT

REM ----- ISOLATE THE RESOLUTION LINE OF MONITOR-1, REMOVING ALL THE OTHER LINES IN THE TEXT FILE
for /f "delims=" %%A in ('type "~TMP.TXT" ^|find.exe /i "Maximum Resolution"') do echo %%A>~TMP.TXT

REM ----- GET THE RESOLUTION NUMBERS OF MONITOR-1, AND SET THEM AS VARIABLES
for /f "tokens=3,4 delims=:X " %%A in ('type "~TMP.TXT"') do (
set _M1_SCREENW_=%%A
set _M1_SCREENH_=%%B
)

REM ----- OUTPUT INFO OF ALL MONITORS TO TEXT FILE
MultiMonitorTool.exe /stext ~TMP.TXT

REM ----- TRY REMOVING MONITOR-1 RESOLUTION LINE (KEEPING MONITOR-2 RESOLUTION LINE)
find.exe /i /v "%_M1_SCREENW_% X %_M1_SCREENH_%" < ~TMP.TXT > ~TMP2.TXT

REM ----- TRY ISOLATING MONITOR-2 RESOLUTION LINE (REMOVING ALL THE OTHER LINES IN THE TEXT FILE)
for /f "delims=" %%A in ('type "~TMP2.TXT" ^|find.exe /i "Maximum Resolution"') do echo %%A>~TMP2.TXT

REM ----- CONDITIONALLY GET THE RESOLUTION NUMBERS OF MONITOR-2, AND SET THEM AS VARIABLES ...
REM ----- CASE(A): IF MONITORS HAVE SAME RESOLUTION, ASSUME NO LINES HAVE STRING "Maximum Resolution". 
REM ----- CASE(B): IF MONITORS HAVE DIFFERENT RESOLUTION, ASSUME ONE LINE HAS STRING "Maximum Resolution".
find.exe /i /c "Maximum Resolution" ~TMP2.TXT
if %ERRORLEVEL% equ 1 (
set _M2_SCREENW_=%_M1_SCREENW_%&set _M2_SCREENH_=%_M1_SCREENH_%
) else (
for /f "tokens=3,4 delims=:X " %%A in ('type "~TMP2.TXT"') do set _M2_SCREENW_=%%A&set _M2_SCREENH_=%%B
)    


REM >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
REM >>>>>>>>>> USER INPUT/PREFERENCES ARE ALL SET HERE [BEGIN] <<<<<<<<<<<<

REM ----- MONITOR-2 LEFT WINDOW PROPERTIES

    set _M2_WINLEFT_=%SYSTEMDRIVE%
    set /a _M2_WINLEFTW_=(%_M2_SCREENW_% / 3) + 50
    set /a _M2_WINLEFTH_=(%_M2_SCREENH_% / 2) + 200
    set /a _M2_WINLEFTX_=(%_M1_SCREENW_%) + (%_M2_SCREENW_% - %_M2_WINLEFTW_%) / 5
    set /a _M2_WINLEFTY_=(%_M2_SCREENH_% - %_M2_WINLEFTH_%) / 2

REM ----- MONITOR-2 RIGHT WINDOW PROPERTIES

    set _M2_WINRIGHT_=%USERPROFILE%
    set /a _M2_WINRIGHTW_=(%_M2_SCREENW_% / 3) + 50
    set /a _M2_WINRIGHTH_=(%_M2_SCREENH_% / 2) + 200
    set /a _M2_WINRIGHTX_=(%_M2_WINLEFTX_%) + (%_M2_WINLEFTW_%)
    set /a _M2_WINRIGHTY_=(%_M2_SCREENH_% - %_M2_WINRIGHTH_%) / 2

REM ----- ADJUST THE WAIT TIME (MILLISECONDS) BETWEEN EACH WINDOW LAUNCH.
REM ----- IF TOO QUICK, THE FOLLOWING WINDOW WILL NOT SET IN THE CORRECT SCREEN POSITION.
REM ----- | FOR FAST SYSTEM: TRY 200 | NORMAL SYSTEM: TRY 400-600 | BLOATED SYSTEM: TRY 800-1200+

    set _WAITTIME_=400

REM ----- ON WINDOWS NT5 (XP, 2000), RUNNING EXPLORER WITH THE 'N' SWITCH WOULD RELIABLY GIVE
REM ----- YOU 1-PANE VIEW (HIDDEN LEFT NAV PANE). ALSO, SHOWING/HIDING OF THE LEFT NAV PANE WAS
REM ----- INSTANTLY TOGGLED BY AN ICON ON THE EXPLORER GUI TOOLBAR.
REM ----- ON WINDOWS NT6 (VISTA, 7), EXPLORER WILL NOT OBEY YOUR COMMANDS AT ALL TIMES AND IT
REM ----- IS A "PITA" TO CONTROL THE GRAPHIC USER INTERFACE. 
REM ----- THIS INPUT SECTION IS A WORKAROUND TO FORCE AN INSTANCE OF NT6 EXPLORER TO BE
REM ----- TOGGLED TO A SPECIFIED VIEW.
REM ----- |
REM ----- | INSERT ONE OF THESE VALUES INTO THE VARIABLE _EXPLORER_VIEW_MYPREF_
REM ----- | | FOR EXPLORER 2-PANE VIEW (SHOW LEFT NAVPANE):  150100000100000000000000E5010000
REM ----- | | FOR EXPLORER 1-PANE VIEW (HIDE LEFT NAVPANE):  1501000000000000000000007B020000

    set _EXPLORER_VIEW_MYPREF_=1501000000000000000000007B020000

REM >>>>>>>>>> USER INPUT/PREFERENCES ARE ALL SET HERE [END] <<<<<<<<<<<<<<
REM >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


REM ----- RUN THE TASK . . .

REM ----- REGKEY 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules' DOES NOT EXIST IN NT5 OR EARLIER
REM ----- BUT TO ELIMINATE DOUBT WE WILL PERFORM A CONDITIONAL VERSION CHECK
for /f "tokens=2 delims=[]" %%A in ('ver') do set _THIS_OS_VERSTRING_=%%A
set _THIS_OS_VERSTRING_=%_THIS_OS_VERSTRING_:Version =%
for /f "tokens=1,2,3* delims=." %%A in ("%_THIS_OS_VERSTRING_%") do set _THIS_OS_MAJORVERSION_=%%A
if %_THIS_OS_MAJORVERSION_% leq 5 goto SKIP1

set _EXPLORER_VIEW_REGKEY_=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer
set _EXPLORER_VIEW_REGVAL_=PageSpaceControlSizer
if exist ~TMP.TXT type NUL > ~TMP.TXT
reg.exe query %_EXPLORER_VIEW_REGKEY_% > ~TMP.TXT
if %ERRORLEVEL% equ 1 goto SKIP1
for /f "delims=" %%A in ('type "~TMP.TXT" ^|find.exe /i "%_EXPLORER_VIEW_REGVAL_%"') do echo %%A>~TMP.TXT
for /f "tokens=1-3 delims= " %%A in ('type "~TMP.TXT"') do set _EXPLORER_VIEW_SYSTEMPREF_=%%C
reg.exe add %_EXPLORER_VIEW_REGKEY_% /v %_EXPLORER_VIEW_REGVAL_% /t REG_BINARY /d %_EXPLORER_VIEW_MYPREF_% /f 2>nul >nul
nircmd.exe wait %_WAITTIME_%

:SKIP1
nircmd.exe exec show "explorer.exe" /n,%_M2_WINLEFT_%
nircmd.exe wait %_WAITTIME_%
nircmd.exe win setsize foreground %_M2_WINLEFTX_% %_M2_WINLEFTY_% %_M2_WINLEFTW_% %_M2_WINLEFTH_%
nircmd.exe wait %_WAITTIME_%
nircmd.exe exec show "explorer.exe" /n,%_M2_WINRIGHT_%
nircmd.exe wait %_WAITTIME_%
nircmd.exe win setsize foreground %_M2_WINRIGHTX_% %_M2_WINRIGHTY_% %_M2_WINRIGHTW_% %_M2_WINRIGHTH_%


REM ----- RESET SYSTEM PREF, CLEAR MEMORY, CLEANUP, QUIT . . .

find.exe /i /c "%_EXPLORER_VIEW_REGVAL_%" ~TMP.TXT
if %ERRORLEVEL% equ 1 goto SKIP2
nircmd.exe wait %_WAITTIME_%
nircmd.exe wait %_WAITTIME_%
reg.exe add %_EXPLORER_VIEW_REGKEY_% /v %_EXPLORER_VIEW_REGVAL_% /t REG_BINARY /d %_EXPLORER_VIEW_SYSTEMPREF_% /f 2>nul >nul
:SKIP2
set _M1_SCREENW_=
set _M1_SCREENH_=
set _M2_SCREENW_=
set _M2_SCREENH_=
set _M2_WINLEFT_=
set _M2_WINLEFTX_=
set _M2_WINLEFTY_=
set _M2_WINLEFTW_=
set _M2_WINLEFTH_=
set _M2_WINRIGHT_=
set _M2_WINRIGHTX_=
set _M2_WINRIGHTY_=
set _M2_WINRIGHTW_=
set _M2_WINRIGHTH_=
set _WAITTIME_=
set _THIS_OS_VERSTRING_=
set _THIS_OS_MAJORVERSION_=
set _EXPLORER_VIEW_REGKEY_=
set _EXPLORER_VIEW_REGVAL_=
set _EXPLORER_VIEW_MYPREF_=
set _EXPLORER_VIEW_SYSTEMPREF_=
del /f /q ~TMP.TXT
del /f /q ~TMP2.TXT
popd
exit
0

The utility "CMDOW Commandline Window Utility" would probably work as well, in conjunction with a control batch file to open and position the browser windows.

http://www.commandline.co.uk/cmdow/

I wrote a fairly involved batch file that would open/rename/relocate DOS-type command windows. Each DOS window represented an instance of a streaming audio capture utility.

The single batch file, would rename the "current" (last opened) command window to a time-stamped "old" command window name. It would then relocated the "old" window to a new screen position. A new "current" command window would then be started, and moved to the screen location previously occupied by the now "old" window.

The allows me to easily identify the old window(s) for manual closing based on their screen location. If more than one "old" windows is active (after running the batch file multiple times) all of the "old" windows would be stacked together at the same screen position. This also allows me the option of closing the "current" window and leave the "old" window active if the batch file had been run incorrectly.

Although I was using this for command windows, it works for any other window types, including browser windows. The multitude of controls for the CMDOW utility and the '@' window identifier is described at the web page above.

Below is a tiny portion of my batch file that specifies the environment variables and the CMDOW commands used. To avoid possible batch problems, I renamed the generic cmdow utility to cmdow.v1.4.3 as to indicate the specific version I am using. The cmdow utility resides in the same directory as the batch file (no special cmdow installation is needed, just run the utility).

REM --------------------------------
REM   SET THE BATCH CONTROL VARIABLES
set strInitialBatchWindow=STARTUP_INSTANCE_OF_stream-1(p)
set   strFinalBatchWindow=CURRENT_INSTANCE_OF_stream-1(p)
set   strBannerTextLine=Audio Stream  (for "Main" channel stream.)
set   strUsualRunPosition= 25 470
set   strRetirePosition= 25 270
set   strWindowSize=668 331
REM

  < Most of the batch setup details have been removed. >

REM move this window instance to it's final "Normal" runtime screen location.
cmdow.v1.4.3 @ /mov %strUsualRunPosition%
REM The following command resizes the current instance window.
cmdow.v1.4.3 @ /siz %strWindowSize%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .