Window

This command creates, opens, closes, activates, and performs several actions on graph and worksheet windows.

Contents

Syntax:

window  option
The option switch determines the action to be performed.

Options:

-a; Set winName as the active window

Syntax: window -a winName

Set winName as the active window.
This option also has the effect of a Windows Restore if the active window is maximized or minimized.

repeat 5 {newbook;}; // Create 5 new workbooks.
window -a book3; // activate Book3 window

-af [n] [millisecond]; Flash active window n times with millisecond timeout

Syntax: window -af [n] [millisecond]

Flash active window n times with millisecond timeout.

win -af;//flash 4 times, use timeout set by @AWF, if @AWF = 0, no flashing
win -af 5;//flash 5 times, use 200ms timeout
win -af 5 300;//flash 5 times, use 300ms timeout
win -af -5;//flash 5 times, follow @AWF for timeout, if AWF=0 no flashing

-an; Activate the winName notes window

Syntax: window -an winName

Activate (restore) the winName notes window.

//to pop up the embedded Notes window.
win -an %@G;

-aw; Go to the URL web page

Syntax: window -aw URL

Go to the URL web page.
View htm files from the local computer (note the use of quotation marks). For example:

// example 1:  Go to the OriginLab home page.
win -aw "http:\\www.originlab.com";
// example 2:  Open htm from the Users Files folder (held in %Y)
win -aw "file://%YmyHelp.htm";

-b; Open or set as active, the specified window

Syntax: window -b winName

Open or set as active, the specified window.
This command option is obsolete. Use the GetNamedWin macro instead.

-c; Delete the winName window

Syntax: window -c <winName>

Delete the window named winName.

In this line of script, the Graph1 window is deleted without prompting the user:

window -c Graph1;

While the window is deleted, the datasets may remain as loose datasets. If you wish to destroy the datasets when the window is destroyed, you can use create -cd/-dd/-nd/-xd.

Also, see the @WD LabTalk System Variable.

-cw; Delete the winName window, wildcard supported

Syntax: window -cw <winName>

Delete the window named winName. This command supports wildcard. For example:

window -cw Graph*;

-ca; Close the winName window

Syntax: window -ca winName

Close the winName window as if the user selected the Close menu command from the child window system menu.
This option prompts the user with a dialog box.

-cwa; Close the winName window, wildcard supported

Syntax: window -cwa <winName>

Close the winName window as if the user selected the Close menu command from the child window system menu.
This option prompts the user with a dialog box.This command supports wildcard. For example:

win -cwa Book*;

-cd; Close the workbook and delete all the data

Syntax: window -cd winName

Close the workbook and delete all the data.

-cwd; Close the workbook and delete all the data, wildcard supported

Syntax: window -cwd winName

Close the workbook and delete all the data. This command supports wildcard. For example:

win -cwd Book*;

-ch; Hide the active window and change the view mode

Syntax: window -ch n

Hide the active window (window's Project Explorer view mode changes).

For example, if the window was in Normal view, it changes to Hidden view (Project Explorer View column) when n = 1. See also, win -h.

newbook name:=Test option:=lsname; // Create a new workbook named "Test", it is
                                   //activated automatically after created.
window -ch 1; // Hide workbook Test.
window -a Test; // Restore it.

-cn; Close the winName notes window without prompting

Syntax: window -cn winName

Close the winName notes window without prompting.

-cwn; Close the winName notes window without prompting, wildcard supported

Syntax: window -cwn <winName>

Close the winName notes window without prompting. This command supports wildcard. For example:

win -cwn Notes*;

-d; Create a duplicate of the active window and make the new window active

Syntax: window -d winName

Create a duplicate of the active window, then make the new window active.
If the winName is not specified, the new window is named Bookn or Graphn, etc. where n is the lowest available number.
This is similar to the -da option, but the new window becomes active. %H indicates the new window name.

-da; Create a duplicate of the active window keeping the current window active

Syntax: window -da winName

Create a duplicate of the active window keeping the current window active.
If the winName is not specified, the new window is named Bookn or Graphn, etc. where n is the lowest available number.
This is similar to the -d option, but the original window stays active. User may find this option useful for example when a window should be duplicated for backup.

-dg; duplicate the current graph window and convert to OpenGL

Syntax: window -dg winName

Origin Version: 9.0 SR0

Create a duplicate of the graph window with winName, or the active graph window if winName is not specified. In the new window, the 3D graph is converted to be OpenGL-based.

This is an example to duplicate and convert all graph window in the current project explorer folder:

doc -ef P //Execute for the given script for all graph objects in the current folder
{
 if(!layer.IS3DGL) // layer.is3dgl is used to determine whether current graph is 3d opengl graph
   {
        win -dg; //Duplicate and convert the current graph window to OpenGL
  }
}

-e; Activate a graph window and delete all data plots

Syntax: window -e winName [template]

Activate a graph window and delete all data plots.
If the window does not exist, create a new window based on a named template and name it winName.
If template isn't provided, then open the window based on the winName template, otherwise open the ORIGIN.OTP template.

-g; Put the path and the template file name into %A

Syntax: window -g

If the active window was opened from a template file, put the path and the template file name into %A.

-h; Hide the active window but do not change the view mode

Syntax: window win -h n

Hide the active window (window's Project Explorer view mode is not changed).

The window's Project Explorer view mode remains set to its current view (for example, Normal or Maximized), but it does not display. See also, win -ch.

-hc; Hide the active or named window and change the view mode

Syntax: window win -hc n [windowName]

This is the same as win -ch, but supports the windowName option.

// Hide Book2, even if it is not the active window:
win -hc 1 Book2;

// Functions just like 'win -ch 1' would:
win -hc 1;

-hn; Hide or show a Notes window

Syntax: window win -hn n NotesWindowName

Hide or show a notes window, where

Minimum Origin Version Required: 8.5.1

-i; Minimize the active window

Syntax: window -i

Minimize the active window.

-ia; Minimize the active window and force activation of the previously active window

Syntax: window -ia

Minimize the active window and force activation of the previously active window.

-in; Minimize the winName notes window

Syntax: window -in winName

Minimize the winName notes window.

-l 0; Put the active window to the end of the Window menu window list

Syntax: window -l 0

Put the active window to the end of the Window menu window list.

-m; Merge all graph windows

Syntax: window -m

Merge all graph windows.

-ma; Prompt with a dialog box before merging all graph windows

Syntax: window -ma

Prompt with a dialog box before merging all graph windows.

-n; Create a new window from scratch and name it winName

Syntax: window -n winType [winName]

Create a new window from scratch (not from a template) and name it winName.

Note 1:

This option is not recommended for creating graph windows.

Use the win -t command option instead. Because you can save most of the graph settings in the template. Default graph template is Origin.otp.

win -t plot MyTemplate Test;

Most of the layer commands in your script will be unnecessary.

Note 2:

After creating a worksheet with the win -n command, you must set the number of rows for the worksheet using the set -er command.

For more control over creating worksheets, use the win -t command or the create command and object.

-o; Execute the specified script for the named window

Syntax: window -o winName {script}

Execute (operate) the specified script for the named window.
winName is temporarily set internally as the active window, the script is executed, then the original active window is re-established.
Most commands operate on the active window. The %H system variable can be used by commands that require a window name.

Note: The window -o is especially useful when user wants to customize the embedded graphs or customize a window which is not active.
example:
//Rescale one layer in the embeded graph
win -o Graph1
{
        Graph1!page.active=2;
        Rescale;
}

-oa; Execute the specified script for the named hidden window

Syntax: window -oa winName {script}

Execute (operate) the specified script for the named hidden window.
winName is temporarily set internally as the active window, the script is executed, then the original active window is re-established.
Most commands operate on the active window. The %H system variable can be used by commands that require a window name.

-os; Add the hidden map boundary worksheet to the root folder

Syntax: window -os Map1

Add the hidden map boundary workbook, named as "Map1", to the project root folder. Each inserted map is added as a separate sheet named for the inserted map. See the Origin Help file for details.

-ppc; Call Project Explorer page preview cleanup function

Syntax: window -ppc

Call graph preview cleanup function to clean graph preview in Project Explorer. When this command is executed, hovering over the graph window in the sub-panel of Project Explorer will not show graph preview.

doc -e p {win -ppc} // Clean all the graph previews from an OPJ

-r; Rename windowName with the given newName

Syntax: window -r windowName newName

Rename windowName with the given newName.

-ra; Open the Rename dialog box

Syntax: window -ra

Open the Rename dialog box.

-rl; Specify a window label and set the window to display the label in the window title

Syntax: window -rl windowName "labelContents"

Specify a window label for the windowName window, and set the window to display the label in the window title.
This is equivalent to:

windowName!page.title = 1; 
windowName!page.label$ = "labelContents";

-rn; Rename notesWindowName Notes window with the given newName

Syntax: window -rn notesWindowName newName

Rename notesWindowName Notes window with the given newName.

-rp; Update windowName with the Short Name or/and Long Name preset in the graph template

Minimum Origin Version Required: 2017 SR0

Syntax: window -rp windowName [strNewName]

If the graph window windowName is created from a template with ShortName and/or LongName preset, this command will update windowName with the preset name and save the updated ShortName in the strNewName variable if present.

Supposed you save a cloneable template "mytemplate" to UFF with Short Name preset. Then activate workbook with prepared data and run the following script to create a graph from the cloneable template and set the graph Short Name.

worksheet -pa ? mytemplate.otp;
win -rp %H strNewName$; //The updated short name is saved in strNewName$

-s C; Window system call to cascade all windows

Syntax: window -s C;

Window system call to cascade all windows.

-s chn, -s cvn; Tile all windows in a certain sequence and then cascade each column

Minimum Origin Version Required: 2015 SR1

Syntax: window -s chn, cvn;

Tile windows horizontally (ch) or vertically (cv) in a certain sequence and then cascade each column. The tile sequence is determined by n:

-s ctn; tile and cascade all windows

Minimum Origin Version Required: 2015 SR1

Syntax: window -s ctn;

Tile and cascade windows. The tile sequence is determined by n, see -s ch/cv above for options of n.

-s T; Window system call to tile all windows

Syntax: window -s T

Window system call to tile all windows by window activated order. The sequences of the activated order is that the latest active window will be tiled first and the first activated window the last.

-s thn, -s tvn; Tile all windows in sequence

Minimum Origin Version Required: 2015 SR1

Syntax: window -s thn, -s tvn;

Tile windows horizontally (TH) or vertically (TV) in a certain sequence. The tile sequence is determined by n, see -s ch/cv above for options of n.

-t; Create a new window from the template file

Syntax: window -t winType template [winName]

Create a new window from the template file.

The window is named winName, or named by default (Graph1, Graph2, etc.) if winName is not given.
If winType, template, and winName are omitted, Origin opens a Bookn worksheet based on ORIGIN.OTW.

This command checks for a path in template and will use this path if specified.
If the path includes spaces, you must surround the path with quotation marks (" ").
For example, use win -t winType c:\MyDir\MyTemp winName to open a winType window based on the MyTemp template in the c:\MyDir directory. Name this window winName.

Use win -t winType MyDir\MyTemp winName to open a winType window based on the MyTemp template in the MyDir subdirectory of the User Files Folder (UFF) or EXE folder. Name this window winName. Whenever loading, it will search first on the UFF and then on the EXE folder.


Note1:

If you close the winName worksheet with the win -c command and then use this win -t command option to open a winName worksheet (where winName is the same with both command options), Origin's behavior is dependent on the value of the @wd system variable.

When @wd = 1, Origin deletes the datasets that remain from the win -c command and then opens the winName window.

When @wd = 0, #Command Error! prints to the Script window.

Origin does not delete the datasets that remain from the win -c command. Additionally, Origin does not open the winName window.


Note2: To open a "master page" from the Master.OTP template, use this command like the following:

win -t plot master master

-t WF; Create a worksheet from the template file and enumerate winName

Syntax: window -t WF template [winName]

Create a window from a named worksheet template file. If [winName] is omitted, the window is assigned a default name (BookN). In either case, window short name is automatically enumerated.

The -t WF switch can be used to create workbooks from the func2d.otw template and enumerate the window short name, as needed. Use in conjunction with the LabTalk copy -w command to paste a dataset copy of a 2D function plot to a workbook created from func2d.otw.

-th; Create a hidden new window from the template file

Syntax: window -th winType template [winName]

Create a hidden new window from the template file.

This feature was broken since Origin 7.5 and fixed in Origin 8 SR2.

-ti; Create a minimized new window from the template file

Syntax: window -ti winType template [winName]

Create a minimized new window from the template file.
This is same with -t option except -ti creates a minimized window.

-tu; Create a new window from the template file but allow Undo

Syntax: window -tu winType template [winName]

Create a new window from the template file and add the window to the undo buffer.

This is identical to the win -t option but it supports "Undo Create".

-tx; Open a new Excel workbook

Syntax: window -tx wks excel

Open a new Excel workbook. See also Set {-ue, -ui}(command)

-w; Temporarily set the active window to winName

Syntax: window -w winName

Temporarily set the active window to winName.
This allows commands that work with the active window to apply to winName.
You must eventually execute win -w to restore normal operation before using the command again.

-w; Restore normal operation before using the command again

Syntax: window -w

Restore normal operation before using the command again.

-z; Maximize the active window

Syntax: window -z

Maximize the active window.

-z0; Fit page to window size

Syntax: window -z0

Fit page to window size, same as this method:

page.zoomwhole=1

-zn; Maximize the winName Notes window

Syntax: window -zn winName

Maximize the winName Notes window.

Examples:

Example 1

This example opens a graph window from the MASTER template (in the software directory) and names the window Master.

win -t plot MASTER Master;

Example 2

The next script opens a new worksheet from the FFT template (in the software directory) and names it by default (Book1, Book2, etc.).

win -t data FFT;

Example 3

This example opens a graph window from the MASTER template located in the C:\MYOWN directory and names the window Master.

win -t plot c:\MyOwn\MASTER Master;

Example 4

This example opens a graph window from the MASTER template located in the MYOWN subdirectory of the software directory and names the window Master.

win -t plot MyOwn\MASTER Master;

Example 5

This example finds the first window in the Window menu window list that begins with graph and sets it as the active window.
If no window is found, it creates a Graph1 window.

win -b graph;

The following script rescales the Graph2 window's X axis from -10 to 10.

win -o graph2 
{
      x1=-10;
      x2=10;
};

Example 6

This example closes the current worksheet together with all associated datasets.

Page.CloseBits=2;  // uses the closebits page property win -ca;

Example 7

This example produces two graphs tiled horizontally while all other windows made iconized.

newbook;wks.nCols=3; //new wkbook with 3 cols
col(1)=data(1,10);
col(2)=normal(10);
col(3)=col(1)+col(2);// fill some data

range aa = (1,2);    // define XYRange
range bb = (1,3);
string strG1$, strG2$; // local string to receive new plot names

plotxy aa ogl:=[<new>];strG1$=%H;
plotxy bb ogl:=[<new>];strG2$=%H;

doc -e o {win -i}; // iconized all windows
win -a %(strG1$);  // opens the two graphs
win -a %(strG2$);

win -s tv;         //and tile vertically

See Also:

System.Display, Clr, Page