ImageJ macro that can select "no" when prompted with "Process Stack?" - process

I have an imageJ macro that involves drawing a line on one slice of a stack. This works great but the only thing that slows this down is the prompt "Process all ### images? There is no Undo if you select 'Yes'."
Is there a way for me to have the macro automatically select "No" when this prompt appears?
Thanks

You can prevent the "Process stack?" dialog by running the Draw command with an option string containing a single space:
run("Draw", " ");
This will only draw on the current slice. If you instead want to draw on the whole stack, you can use:
run("Draw", "stack");
EDIT:
The bug causing incorrect macro recording (run("Draw");) when using the D shortcut was fixed in a recent commit: it now records run("Draw", "slice");

Related

Mapping Keyboard Shortcuts in Word (vba) KeyBindings.Add KeyCategory: = wdKeyCategoryCommand, Command: = "..."

Good day.
Someone has a list of the commands that can be assigned a keyboard shortcut using the function:
KeyBindings.Add KeyCategory: = wdKeyCategoryCommand, Command: = "..."
I want to assign a shortcut to decreasing French indentation, but I only see the command for its increase: Command: = "HangingIndent"
Thank you. Greetings.
Choose Developer>Macros. Change the Macros in dropdown to Word commands. The complete list of available command names is displayed.
If you need to set specific indentation amounts, you'll have to write a simple macro instead of relying on Word's preset indentation values.
But it's probably better to avoid VBA altogether. Instead of relying on local formatting (which a Word command or macro would do), create a typestyle with your preferred indentation and apply that to the text. That's a better practice in Word and easy to update later if you change your mind about the amount of indentation.
The problem is precisely that, that the command related to the decrease of the French indentation does not appear in the list of Word commands. What I need to know is what the said command is called. After a lot of thinking I found a command to list all the keyboard shortcuts in the active document: Application.Run MacroName: =" CommandList" and this allowed me to find what I'm looking for: RemoveHangingIndent

How to send a new line without using `n `r? without an enter

i know that n means "ENTER", but when i'm using n, i dont want to press enter. I just want to put the text in a new line, but what "n" does, it puts in a new line but it also press enter.. i don't want to press enter...
For example
::pergunta::Hello, n How are you? n what are you doing? n bye...
How can i fix that issue?
First, you need to determine what keystrokes your application uses for this purpose, and then you can implement that in Autohotkey.
For example, in Excel, multiple lines of text can be typed into a single cell by pressing ALT-ENTER at the end of each line (instead of ENTER).
So, the following AutoHotkey script would work for Excel:
:X:pergunta::Send, Hello,!{Enter}How are you?!{Enter}what are you doing?!{Enter}bye...
The ":X:" at the beginning means "run a script", which in this case is the "Send" command. The !{Enter} part means ALT-ENTER.
You might also want to use SetKeyDelay to speed up the typing of text:
SetKeyDelay, 0
:X:pergunta::Send, Hello,!{Enter}How are you?!{Enter}what are you doing?!{Enter}bye...

Step into when opening another workbook

I'm trying to debug code using "Step into", but first part of my code requires another workbook to be opened by TextBox. So "Step Into" just stops when TextBox appears (I mean that there is no opportunity to choose file via button or fill by keyboard).
Is there another way to debug code step-by-step or way to avoid this stuff?
Thanks in advance!
You can (temporarily) add code to cause a break
Debug.Assert <Some Condition that returns FALSE when you want to break>
eg
Debug.Assert False

Run macro at key press - Space key

I have a Word 2013 Macro which quickly runs a simple spell check dialogue.
I want to run it every time I type a word.
One way of doing this is by running the macro every time I press space.
Therefore, I tried to use the Options>Customize Ribbon>Keyboard Shortcuts method but that did not work for the space key.
How can I run a macro every time press the "space" key?
Thank you in advance.
You should be able to do this using KeyBindings. I've not tried it with spacebar specifically, but I use this with tab, backspace, etc. The basic idea is:
in a sub that you run at startup or document open:
'This line may differ depending on whether you are running this from a document template or an add-in.
Application.CustomizationContext = ThisDocument.AttachedTemplate
' Create the keybinding.
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeySpacebar), KeyCategory:= _
wdKeyCategoryMacro, Command:="MyMacro"
Then make sure your macro is named to match whatever you put in Command.

Read undo history in VBA

I have a fairly simple bit of VBA in Word 2003 that changes the document's font to an 'eco font' (long story), and brings up the Print dialog.
When a user hits Cancel or OK, the code does an 'undo' to revert the change.
The problem is, sometimes when I press "OK" to print the document, two actions need to be undone ('font change', and 'update fields'). I can't seem to predict when this will happen.
Is there any way of reading the last item in Word's undo buffer? That way I can just keep pressing undo until the font change has been completed.
Edit:
Final code (cut down):
ActiveDocument.Range.Bookmarks.Add ("_tempEcoUndoStart_")
ActiveDocument.Content.Font.Name = "Nanonymus Eco Sans"
Dialogs(wdDialogFilePrint).Show
While ActiveDocument.Bookmarks.Exists("_tempEcoUndoStart_")
ActiveDocument.Undo
Wend
You can use a trick to have a 'transactional'-like undo in Word: At the beginning of the macro place a special bookmark on your entire document. You should remove this bookmark again when you are done with your macro. Now, when calling the Undo command, repeat the undo while there is your special bookmark in the document.
The following related question has the details:
Can I create an undo transaction in Word or Excel? (VSTO)
I have not tested, but perhaps you can use UndoClear before your actions, and a count on undo after?
ActiveDocument.UndoClear
ActiveDocument.Undo 2