Navigating by keyboard to remove empty lines between paragraphs

Although I can navigate via the mouse to Edit > Text Tidying > Remove Empty Lines Between Paragraphs, I want to be able to do this via keyboard.

Scrivener does not have a keyboard shortcut for this. Also, it will not allow me to make a keyboard shortcut. So I am left with navigating via separate keystrokes.

See the screenshot:

Here is my question: Shouldn’t I be able to do this by typing Alt E > D > R? I can get Alt E to open the edit menu, but D does not navigate me to Text Tidying.

Since I can use this same process to open pretty much any other menu item, I wonder if this is a bug. I’d appreciate any suggestions from more experienced users.

Yes, I’ve run into this same problem many times. :slight_smile:

The issue is that the accelerator key ‘d’ is colliding with the Edit ▸ Delete entry, which is disabled in this case (fortunately!) and thus fails. It’s a problem with the toolkit as well, in that in my opinion if there is a collision, that shouldn’t be the end of things because tapping ‘d’ repeatedly would cycle between options. Normally it does, but it breaks when one of the entries is disabled.

That said, we really should not have a collision between a perfectly safe to open submenu, and a disruptive command like ‘delete’! I’ll make sure we have a ticket open on that.

As for it having an entry in the shortcut list, this does have an open ticket. Really the ticket is for all menu commands to be added to the list, but as it takes manual effort to do so, this has never happened, and instead it gets gradually added to over time.

My trick, by the way, is: Alt,e,↑,↑,→, to get into this menu.

2 Likes

Amber, I really appreciate your taking the time to catch me up. This is the context I needed.

Your trick of Alt, e, ↑, ↑, → is super helpful. My end goal is to make a script via AutoHotKey. I can have the script mimic these keys and assign the whole thing to a keyboard shortcut. Once I do that, I can assign a Stream Deck key to the newly made shortcut, and voila, I’ll have my automation. :disguised_face:

By the way, an aha moment was realizing, thanks to your help, that I could map the script to up arrows; when I had tried down arrows, it wouldn’t faithfully recreate the action. The up arrows approach has fewer steps and perhaps bypasses something that is stopping the script’s iteration, so I’m optimistic it’ll work.

1 Like

The accelerator key D is allocated to the following on the Edit menu:

  • Delete
  • Append Selection to Document
  • Link to Document
  • Text Tidying

Weird.

2 Likes

Success!

Using @AmberV 's keystroke iteration (but adding a final down key press), I could write a script for AutoHotkey to automate the navigation. This is the first time I’ve tried AutoHotkey; I’ll probably use this approach as a workaround should I encounter any more accelerator key collisions in Scrivener until the developers sort this out.

With this solved, I added a button to Stream Deck to execute the AutoHotkey script with the push of a button. It goes alongside the button to turn straight quotes into curly quotes. They are enjoying each other’s company. :slight_smile:

In case it’s helpful, here is the script for AutoHotkey:

if WinExist("ahk_exe Scrivener.exe") 
{
    WinActivate  ; Activate Scrivener
    Sleep 100    ; Brief pause to ensure the window is active
    Send "!e"    ; Press Alt+E to open the Edit menu
    Sleep 200    ; Allow time for the menu to open
    Send "{Up}"  ; Navigate up one item
    Sleep 200
    Send "{Up}"  ; Navigate up another item
    Sleep 200
    Send "{Right}"  ; Open the submenu
    Sleep 200
    Send "{Down}"  ; Navigate down another item
    Sleep 200
    Send "{Enter}"  ; Select the option in the submenu
}
1 Like

Thanks for sharing the AHK script. If you search the forums for AHK, you’ll find a few other scripts shared. :nerd_face:

I’d never heard of Stream Deck before. Which device do you own?

Best,
Jim

1 Like

Jim, I own the Stream Deck XL. It has more keys than I need for Scrivener, so a less pricey Stream Deck model with fewer keys would also work for writers.

This photo shows it in my composing and writing studio just below the monitor, on the right just above the MIDI keyboard. It’s become indispensable to my creative workflow.

5 Likes

Sweet setup! Love that ultra wide monitor over the keyboard for displaying scores. :musical_score:

1 Like

I just came across the thread now and wanted to offer my two cents worth. I’ve been using AHK since before I started using Scrivener which was about 10 years ago. I have a large library of AHK scripts that streamline many aspects of Scrivener that I’d be happy to share if others are interested. Streamdeck + AHK is an awesome combination for streamlining your workflow so you can focus on writing instead of navigating menus.

I have three Streamdecks: legacy 15 button; Streamdeck XL; and Streamdeck Plus. It might sound like overkill but I move around a lot in Scrivener and I use all of those buttons.

I always have my Scrivener screen layout the same: Scrivener open in my front monitor fullscreen, and my two side monitors displaying various QR windows. Having your Scrivener window in the same place all the time is important because it means you can write AHK scripts using screen coordinates instead of relying on keyboard shortcuts. For example, I always have Scrivener set to backup my project to a zip file when I close the project. But occasionally I want to close Scrivener without backing up. The following script toggles Backup on Close on and off, but it relies on screen coordinates:

!+F13:: ;Scrivener: use Alt+Shift+F13 to toggle backup on close
{
Send “^{,}” ;open Options dialog
Sleep 500
Click 2330, 50 ;open Backup tab
Sleep 200
Click 45, 225 ;check box for Back up on project close
Sleep 200
Send “{Enter}”
}

Also, note that I use F13. Windows recognizes F13 through F24 even though keyboards don’t have buttons for them. But devices like Streamdecks can reference them. And I believe Scrivener can too—I believe you can assign an extended function key to a shortcut in Scrivener, just like you can in Autohotkey, then trigger it with a Streamdeck button.

I find AHK so incredibly helpful that I keep thinking other Windows users would as well, if they understood what it does and how easy it is to learn. I’m happy to share my scripts and support anyone who’s trying to figure it out.

3 Likes

Tom, I have the same thought exactly. AHK has helped me make access to frequently used key combos super efficient. I suspect, though, that for most Scrivener users, even doing light coding is a bridge too far.

Feel free to post any of your scripts to this thread. It needs some love. :grinning_face:

Tom, I’m a newbie to AHK, so it would be great to see any scripts relating to Scrivener that you’ve cooked up. Thanks for jumping in here. :slight_smile:

As an aside, I’ve recently discovered that Stream Deck has less robust but often adequate multi-step actions to automate things, too. It’s quite a bit easier to use, as it’s GUI-based and doesn’t require scripting knowledge. (I can write scripts if I have to, but I prefer the simple GUI approach that Stream Deck offers.) That said, Stream Deck doesn’t, to my knowledge, provide conditional logic, so it can’t test to see if a certain app is already launched–something I needed to do with the script I wrote and shared above. So AHK can do things Stream Deck can’t, to be sure.

Jim—thanks for your note. I agree that even light coding might be more than most would want to jump into. But I also think that an awful lot of users just don’t know that AHK even exists. I’ve wondered whether there’s some way to communicate that to the broader community other than monitoring people’s requests for help on the Windows forum and suggesting it as a solution. Maybe offering to host a webinar on AHK for Scrivener sometime?

And, while this would likely be even more over many people’s ambitions, Claude and Gemini have become really good at generating AHK scripts, making it much easier to create scripts without understanding too much about AHK.

In any case I’ll post some scripts and see if folks respond. Thanks for initiating this sub-forum and keeping it alive!

Hi SCN—thanks for your note. Yes, Streamdeck does have a very basic capability to program its keys. But once you get to know AHK it’s pretty much as fast as Streamdeck. For me one of the big advantages of AHK is that the scripts are not tied to a device. For years I used a Loupedeck, which was great until Logitech bought Loupedeck then killed the product. I was able to take all my AHK scripts that I’d assigned to Loupedeck buttons and dials and just reassign them to Streamdeck buttons and dials. And I can choose to execute AHK scripts both from the keyboard and the Streamdeck.

You’re probably aware of this, but in case you’re not, if you go into Settings on Streamdeck and select the Profiles tab then select the Profile you’ve written, you can assign that profile to an application. That will activate the profile whenever that application is open. But it is much more limited than AHK. The If WinEXIST function you use is much more robust. In Streamdeck once a key is programmed, it will execute when pressed no matter what application is open. With the If WinEXIST function, it only executes when that application is active. This means you can reuse the same shortcut keys in different ways in different applications.

I’m about to post a number of scripts to the AHK thread that Jim started. I hope they’re helpful. They’re all pretty simple. I’m happy to answer any questions or help if you’re getting stuck with a script.

3 Likes

One more note to my previous posts: The Automator is a fabulous resource for anyone learning or using AutoHotkey.

They have weekly calls anyone can join with questions, they’re incredibly knowledgeable and love to help people out, and have lots of utilities and online courses related to AHK. I’m not associated with them, I just use them when I have questions or need help with something beyond my expertise.

2 Likes

In case anyone would like to visit the AutoHotKey macros discussion, it is here: Please share your AutoHotKey macros for Scrivener

1 Like

@TomGoodell, I’m heading over to look at the scripts you’ve shared.

You’ve convinced me that it is better practice to build the macros in AHK and then assign them to a button in Stream Deck, rather than build them directly in Stream Deck. I could then document the scripts in my notes (in my case, Obsidian) in case I ever needed to refer to or recreate them.