Ability to Assign Highlighting to a Hotkey

Didn’t know I could do that. Thanks for the tip!

John

1 Like

Hi John,

If you do Ctrl+Shift+H, Scrivener will highlight any selected text with the last used Highlight color.

Wasn’t sure if you were aware of that, but it’s a feature available now in Windows Scrivener.

Best,
Jim

2 Likes

Thanks Jim, I did see that just now as I was looking through the shortcuts. If I can remember what the last color was I used, it’ll come in handy!

John

Try one of these. I use Karabiner and Keyboard Maestro, extensively.

hot key solutions

Hi John,

Here 's an Autohotkey script that would do what you want.

Ctrl+Shift+1 highlights text in Cantaloupe.

Ctrl+Shift+2 highlights text in Pink Marker.

The script works by doing Alt+ R, H, arrow down x 3, enter. (Selecting Cantaloupe)

You can assign different hotkeys by tweaking the script, but avoid using Alt as your hotkey. And you can change the color selected by changing the Down count. Of course, you can add more hotkeys and colors.

Let me know if you have any questions about how to set up Autohotkey.

Best,
Jim

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;--------------------------------------------------------------------------	

SetTitleMatchMode, 2

#IfWinActive ahk_class Qt5153QWindowIcon

;--------------------------------------------------------------------------	

^+1:: ; Ctrl+Shift+1 =  Cantaloupe

Send !r
Send h
Send {Down 3} ; Cantaloupe
Send {Enter}

return


^+2:: ; Ctrl+Shift+2 =  Pink Marker

Send !r
Send h
Send {Down 4} ; Pink Marker
Send {Enter}

return


Thanks!

I was wondering if I could do it with AutoHotKey, and now you’ve saved me the trouble!!

Much appreciated.

John

I have AutoHotKey installed-- can you give me a couple of quick tips how to get this script loaded-up and running? I’ve got years of programming experience, but haven’t used AHK yet, apart from installing it.

John

Hey - It worked !! :slight_smile:

Thanks

To anybody who’s interested, here’s an updated script, using the same key setup (CTRL+SHIFT+1 through 6) for the markers.

Here’s a screenshot for reference:

And here’s the AutoHotKey (.ahk) Script:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;--------------------------------------------------------------------------	

SetTitleMatchMode, 2

#IfWinActive ahk_class Qt5153QWindowIcon

;--------------------------------------------------------------------------	
;; CLEAR

^+1:: ; Ctrl+Shift+1 =  CLEAR

Send !r
Send h
Send {Down 1} ; CLEAR MARKER
Send {Enter}

return

;--------------------------------------------------------------------------	
;; YELLOW (Banana)

^+2:: ; Ctrl+Shift+2 =  YELLOW 

Send !r
Send h
Send {Down 2} ; YELLOW MARKER
Send {Enter}

return

;--------------------------------------------------------------------------	
;; ORANGE (Cantaloupe)

^+3:: ; Ctrl+Shift+3 =  ORANGE 

Send !r
Send h
Send {Down 3} ; ORANGE MARKER
Send {Enter}

return

;--------------------------------------------------------------------------	
;; RED (Pink)

^+4:: ; Ctrl+Shift+4 =  RED

Send !r
Send h
Send {Down 4} ; RED MARKER
Send {Enter}

return

;--------------------------------------------------------------------------	
;; GREEN (Honeydew)

^+5:: ; Ctrl+Shift+5 =  GREEN

Send !r
Send h
Send {Down 5} ; GREEN MARKER
Send {Enter}

return

;--------------------------------------------------------------------------	
;; BLUE

^+6:: ; Ctrl+Shift+6 =  BLUE

Send !r
Send h
Send {Down 6} ; BLUE MARKER
Send {Enter}

return
2 Likes

BTW – to the DEVS –

I’d still like to request this ability get built into the program, so I don’t need an external program to make it work.

Thanks

(And thanks everyone for all their help!!)

John

You can do it easily with character styles. That makes it simple to remove all formatting of a specific color by redefining the style or deleting it. Don’t forget to override those styles in Compile to remove the highlighting (if you don’t want to Compile it).

That does work with compiling and whatnot. But the highlighting is dynamic-- or maybe better, on-demand / as-needed. I set it to flag an issue. I clear it later when the issue is resolved. In between, I have requests to read, and often send out a version of the WIP with the highlighting intact. So the solution to be able to show/disable it in compiling is good. With regular compiling, I can do it with one switch (remove highlighting). But that’s a minor difference, and YOUR solution might actually turn out to be more adroit, given that I could turn on/off styles by style.

The solution Jim suggested, with the AutoHotKey script, is a good workaround. I modified it a little (even from the one I posted) so that CTRL-7 through 9 are Orange, Red, and Green. CTRL-0 is Clear Highlighting. That fit in with the Scrivener shortcut keys and covers 95% of my use cases.

But I still would prefer the highlighting be available to apply via shortcuts within the program. I don’t care if they’re not hooked-up. There is a facility to defining shortcuts to functions. Just stick the Highlight functions in there, and if I care, I’ll figure out how I want to add them. IMO, I would consider that “Job Done”.

I still like your suggestion though. I think it could come in handy for a variety of other things I’d like to be able to do. The biggest one is to be able to turn off the “Goals” section of my way of doing it when I compile.

The clear advantage of my approach is removing all highlighting of a given color in one go in the Editor, not just in Compile. If the “remove all highlighting” switch overrides character styes (I’d have to test that), I think the other method has no advantages at all.

I don’t think the “remove all highlighting” button changes the character style, just removes the colored background.

… and only in Compile.

Hi John,

It just occurred to me that one possible built-in solution for what you want is Scrivener’s Revision Mode.

I haven’t used it in a while, so forget precisely how it works, but you can assign keyboard shortcuts to highlight colors.

By default, there are none assigned.

image

You can assign shortcuts in Options:

And you can change the Revision Colors in Options:

Check it out, if it sounds promising to you.

Best,
Jim

Thanks, Jim for thinking about that. I’ve looked at it before and it only allows you to change the text color, not add highlighting. Though, apart from that, it’s a reasonable suggestion. It could even maybe work as an alternate to the inline annotations I’m using now to indicate the synopsis and so forth.

However, I must say that your AutoHotKey suggestion was a very good one. I’ve been using that to very good effect and have been pretty happy with it. I’d still like to see the ability to do it within the program get added, but the AHK workaround is a “Works for me” until it does.

I ended up modifying the one I posted by putting Orange, Red, Green, and Clear on CTRL-7 through CTRL-0. Works like a charm. It isn’t every color, but certainly encompasses probably 80-90% of my use case. So I’m happy with it.

John

1 Like

Doh! Yes, of course you’re correct, John, revision mode is about text color, not highlighting.

Glad that AHK is filling the need for the moment. AHK has proved to be a good way to make workarounds. I’ve found that script in the other thread very useful for the Scrivenings PageUpDown issue.

Best,
Jim

1 Like

Hi. I realize this thread is a little dated, but I just started working with AHK over the past few days. I had a great macro (purchased) for Word that could toggle through several highlight colors by using Ctrl+Shift+Plus/Minus. The AHK code shown here isn’t quite the same, but it still looks helpful.

For some reason, though, I can’t assign any highlighting to Ctrl+Shift+a number. The script words with Ctrl+j, but not with Ctrl+Shift+0, for example. (I used Ctrl+j because that’s the hotkey used in the first few examples in the AHK tutorial.)

Any idea why I can’t assign this to Ctrl+Shift+a number? I tried several variations today, and sometimes it sent the cursor to the end of the section of text, if that’s any help.

Ctrl+Shift is one of the standard Windows shortcuts for switching between keyboard layouts, and it can be assigned with the addition of a number to go to a specific keyboard layout. Any chance you have your system set up that way? (Depending on your Windows version, I think it’s something like Settings > Devices > Typing > Advanced Keyboard Settings > Input Language Hot Keys.)