window handlers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

window handlers

Braekevelt Martin
Dear all,

How can i use macro code to use the selection buttons in a window without need to selected by the mouse. Ex. After opening the image i just want to have the window maximized without clicking the square in the window header.
Also after using the get.directory and clicking the folder I need, use the select button directly from the macro code.
Using the close command without save.
There are a lot of these things in windows I like to select from the code, it would save a lot of mouse clicking.

Thanks for your help in advance.

Kindest regards,
Martin.
::DISCLAIMER:: This e-mail is confidential and intended for use by the addressee only. If you are not the intended recipient, please notify us immediately and delete this e-mail, as well as any attachment. ::DISCLAIMER:: This e-mail is confidential and intended for use by the addressee only. If you are not the intended recipient, please notify us immediately and delete this e-mail, as well as any attachment.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: window handlers

Michael Schmid
Hi Martin,

for maximizing a window, you need Java or a scripting language like
Javascript, which can access Java methods. Javascript example:

imp=IJ.getImage();
win=imp.getWindow();
win.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
IJ.wait(1000);
win.setExtendedState(java.awt.Frame.NORMAL);  //back to normal
// you have to set the desired zoom level therafter.

You can use a macro call to execute JavaScript in a macro:
   eval("script", <javascript_code>);

https://imagej.nih.gov/ij/developer/macro/functions.html#eval

--
Concerning getDirectory():
I don't think that you can interfere as long as the dialog for choosing
a directory is open.
Anyhow, selecting a directory with a single click would be possible only
it the user must not transverse the hierarchy; double-clicking is needed
to open a directory to access deeper levels (and in your scenario, the
first click of double clicking would already select the directory and
close the dialog).
If you have only one level and you know where you want to start, you
could create your own dialog.
In a macro, you could create a blank image with the names of the
directories available (as texts, maybe with some nice frames around
them) that the user may choose, and then in a loop use
   getCursorLoc(x, y, z, modifiers)
until the modifiers indicate the user has clicked.

https://imagej.nih.gov/ij/developer/macro/functions.html#getCursorLoc

--
Allowing the user to close an image without asking whether to save:
While the image is in the foreground, use
   setOption("Changes", false);

https://imagej.nih.gov/ij/developer/macro/functions.html#setOption

Michael
________________________________________________________________
On 24/10/18 13:39, Braekevelt Martin wrote:

> Dear all,
>
> How can i use macro code to use the selection buttons in a window without need to selected by the mouse. Ex. After opening the image i just want to have the window maximized without clicking the square in the window header.
> Also after using the get.directory and clicking the folder I need, use the select button directly from the macro code.
> Using the close command without save.
> There are a lot of these things in windows I like to select from the code, it would save a lot of mouse clicking.
>
> Thanks for your help in advance.
>
> Kindest regards,
> Martin.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: window handlers

Braekevelt Martin
Dear Michael,

Thanks for the support. I will try this out.

Kindest regards,
Martin.

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Michael Schmid
Sent: Wednesday, October 24, 2018 5:43 PM
To: [hidden email]
Subject: Re: window handlers

Hi Martin,

for maximizing a window, you need Java or a scripting language like Javascript, which can access Java methods. Javascript example:

imp=IJ.getImage();
win=imp.getWindow();
win.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
IJ.wait(1000);
win.setExtendedState(java.awt.Frame.NORMAL);  //back to normal // you have to set the desired zoom level therafter.

You can use a macro call to execute JavaScript in a macro:
   eval("script", <javascript_code>);

https://imagej.nih.gov/ij/developer/macro/functions.html#eval

--
Concerning getDirectory():
I don't think that you can interfere as long as the dialog for choosing a directory is open.
Anyhow, selecting a directory with a single click would be possible only it the user must not transverse the hierarchy; double-clicking is needed to open a directory to access deeper levels (and in your scenario, the first click of double clicking would already select the directory and close the dialog).
If you have only one level and you know where you want to start, you could create your own dialog.
In a macro, you could create a blank image with the names of the directories available (as texts, maybe with some nice frames around
them) that the user may choose, and then in a loop use
   getCursorLoc(x, y, z, modifiers)
until the modifiers indicate the user has clicked.

https://imagej.nih.gov/ij/developer/macro/functions.html#getCursorLoc

--
Allowing the user to close an image without asking whether to save:
While the image is in the foreground, use
   setOption("Changes", false);

https://imagej.nih.gov/ij/developer/macro/functions.html#setOption

Michael
________________________________________________________________
On 24/10/18 13:39, Braekevelt Martin wrote:

> Dear all,
>
> How can i use macro code to use the selection buttons in a window without need to selected by the mouse. Ex. After opening the image i just want to have the window maximized without clicking the square in the window header.
> Also after using the get.directory and clicking the folder I need, use the select button directly from the macro code.
> Using the close command without save.
> There are a lot of these things in windows I like to select from the code, it would save a lot of mouse clicking.
>
> Thanks for your help in advance.
>
> Kindest regards,
> Martin.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html