Return keystroke not activating

I'm trying to create a shortcut to "quit the kernel" in Mathematica. To do this manually, I need to go into the menu and execute: Evaluation->Quit Kernel->Local. This then brings up a dialog asking me if I really want to quit the kernel, giving me the the option of answering in the affirmative by pressing "Return":

I'm trying to create a Macro to do this. It contains two items:

The first item (Evaluate->Quit Kernel->Local) works fine, since it does result in the above dialog. The problem is the second item—it is not typing the Return key. Here's a screenshot of the macro:

Also, why does the second item have diagonal blue bars in the background?

  1. Try an action to Click a Button "Quit" instead of a keystroke or try a space-bar keystroke instead?

  2. The blue bars are for when something matches a search term. (I just asked about this recently, too!)

Edited to add: the space-bar suggestion was a bad one, so I removed it -- TjL

1 Like

Thanks! Tried using Press a Button "Quit", and it works, except for one buggy thing: When you do this w/o KM, immediately after pressing Return, a "working" icon appears on the screen for a second and then goes away. But with the KM macro, that icon sometimes persists on the screen for several seconds (you can make it go away by moving the cursor). Not sure why that's happening, but I I can live with that.

Also tried your Space-Return suggestion, but I'm not sure how you meant me to implement it. I tried adding a command to press and hold the space bar, followed by press and release Return, and that didn't do anything. Also curious why you suggested that, since the action itself is to just hit Return.

Finally, I'm curious why my original macro wouldn't work, since asking KM to simply press Return would seem to be the cleanest solution.

So that the macro does not hang @theorist, I would set an action "Pause Until..." for the "Type a Keystroke".
Then it should also work with the return :wink:


1 Like

If you use @theorist instead of Return the Space key in "Type a Keystroke" you would press the Cancel button.
If a button like this is highlighted in blue, you can work with either Return or the button action (Quit).

Thanks! That explains why my original approach didn't work! With that, it does. Though I'll note the same small bugginess I found with tjluoma's Press Button approach (the persistence of the "working" icon (i.e., "waiting for system to respond") (which actually looks like a wrist watch) also appears here. But as mentioned above, I can live with that.

1 Like

Probably the keystroke is being typed before Mathematica is putting up the dialog.

Use a short Pause action, or a Pause Until action with the Button condition to pause until the Quit button is available, and then either Type a Keystroke Return, or Press a Button action.

1 Like