Stacking Windows Macro

Get help using and writing Nisus Writer Pro macros.
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Stacking Windows Macro

Post by bjast »

New to Nisus.

How would I go about writing a macro to automatically stack all of the open windows exactly on top of each other?

Thanks
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Stacking Windows Macro

Post by Kino »

If I don’t misunderstand you, you don’t need a macro for that. With the option key pushed down, “Bring All to Front” command under Windows menu will change to “Arrange in Front” which does the job. This command is available in many OS X applications.
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Stacking Windows Macro

Post by bjast »

That's a nice feature, and close to what I had in mind. But what I actually would like is for all of the windows to stack 'exactly' on top of one another. Guess I'm just a neat freak, but it helps me concentrated on the current document.

I have set my Desktop background to the same color of the background of my NWP docs, so it appears as though the front doc is the only thing on the entire screen.

Thanks
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Stacking Windows Macro

Post by Kino »

bjast wrote:But what I actually would like is for all of the windows to stack 'exactly' on top of one another.
That is not feasible. There is no macro command for getting/setting the coordinates of a document window.
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Stacking Windows Macro

Post by bjast »

That's unfortunate. I suppose that means that the Arrange in Front command - implemented by pressing Option while selecting Window > Bring All to the Front - is system-wide, and not unique to NWP.

Is there a way to hide a window that, perhaps, could be exploited through a macro to hide more than one window in succession?

Thanks
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Stacking Windows Macro

Post by Kino »

A macro can hide a window but only while a macro is running. So it is not usable for this purpose. But perhaps minimizing all windows except the frontmost would achieve something close to what you need?

Code: Select all

$frontmost = Document.active
if $frontmost == undefined
	exit
end

$docs = Document.openDocuments
foreach $doc in $docs
	$doc.show
	if $doc != $frontmost
		Send Selector 'miniaturize:'
	end
end
The macro above de-minimizes documents already minimized before minimizing them. That is inelegant but there is no way for a macro to know if a document is minimized or not.

And the following shows (de-minimizes) all open documents.

Code: Select all

$docs = Document.openDocuments
if $docs != undefined
	foreach $doc in $docs
		$doc.show
	end
end
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Stacking Windows Macro

Post by bjast »

Thanks Kino. I'll check this out.

It's intriguing that, for as extensive as it is for writing macros, NWP does have a way to handle the coordinates of open windows.

Curious ...
dshan
Posts: 334
Joined: 2003-11-21 19:25:28
Location: Sydney, Australia

Re: Stacking Windows Macro

Post by dshan »

bjast wrote:That's a nice feature, and close to what I had in mind. But what I actually would like is for all of the windows to stack 'exactly' on top of one another. Guess I'm just a neat freak, but it helps me concentrated on the current document.

I have set my Desktop background to the same color of the background of my NWP docs, so it appears as though the front doc is the only thing on the entire screen.

Thanks
If that's all you want then why not simply use View>Full Screen mode? Then the front window is the only thing on the entire screen.
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Stacking Windows Macro

Post by bjast »

dshan wrote:If that's all you want then why not simply use View>Full Screen mode? Then the front window is the only thing on the entire screen.
Good observation. I would do as you suggested if there were not the limitations (bugs?) that currently exist in the Full Screen Mode: See this thread:

http://nisus.com/forum/viewtopic.php?f=18&t=3645
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Stacking Windows Macro

Post by Kino »

bjast wrote:It's intriguing that, for as extensive as it is for writing macros, NWP does <not> have a way to handle the coordinates of open windows.
Even if the Full Screen view did not have those bugs or limitations, I think NWP macro should have commands for inspecting/modifying window coordinates (available in NW Classic) as well as a command reporting the text range of the currently visible area of a document (necessary for a Top of Page macro requested by you in another thread). So I just sent them a feedback requesting those commands. They will be a significant enhancement for the NW Pro macro language. Thank you very much!
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Stacking Windows Macro

Post by bjast »

Thanks Kino for adding < not > to my previous message. Am I hearing you correctly, that NW offers these window coordinates, and NWP does not? That is curious indeed, as you would think you were getting a more advanced product with the "Pro" version.
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Stacking Windows Macro

Post by Kino »

Yes, the following commands (or rather keywords) are available in NW Classic macro.

RectRight Nisus[FrontWindow][WindowRect][...]
RectLeft Nisus[FrontWindow][WindowRect][...]
RectTop Nisus[FrontWindow][WindowRect][...]
RectBottom Nisus[FrontWindow][WindowRect][...]


I did not use them so often but they were indispensable for a macro which force-redraws document windows. I wrote it in order to solve a Classic environment issue.

Although NW Pro macro is much more advanced, efficient, and extensive in many points, not all NW Classic macro features are available yet. The most important missing one would be the ability to record a macro. Of course, we should understand that NW Pro/Express is not an updated version of NW Classic but a new application written from scratch and that something easily feasible in legacy Mac OS is not always so in OS X, though.
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Stacking Windows Macro

Post by bjast »

Thanks for the insight. Being new to NWP and Nisus in general, I didn't realize that NWP was a complete rewrite. This helps me to make more sense out of its limitations.
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Stacking Windows Macro

Post by Kino »

kino wrote:The macro above de-minimizes documents already minimized before minimizing them. That is inelegant but there is no way for a macro to know if a document is minimized or not.
I sent a feedback requesting such macro commands and Martin kindly reminded me of isVisible command. So here is a revised version.

Code: Select all

### Minimize All Windows except the Frontmost ###
$frontmost = Document.active
if $frontmost == undefined
	exit  # because no window is open
end

$docs = Document.openDocuments
$docs.removeValueAtIndex 0  # exclude the frontmost document
foreach $doc in $docs
	if $doc.isVisible
		Document.setActive $doc
		Send Selector 'miniaturize:'
	end
end
Unfortunately this macro still cannot handle all possible situations. It is impossible to know in which space a document window is situated. In other words, the macro will minimize windows which are visible in other spaces, too. I don’t know if there is any user who puts NWP document windows in different spaces, though.
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Stacking Windows Macro

Post by bjast »

Thanks Kino. This is an improvement and does a good job of minimizing all but the frontmost window.

The challenge I'm finding is that I work with multiple windows at a time, and need to Command Tilde rotate between them. This, obviously, doesn't work when the windows are minimized.

Hopefully, they will add the option you requested to a future version of NWP.

Thanks
Post Reply