# AHK Palette for Windows Scrivener

**URL:** <https://forum.literatureandlatte.com/t/ahk-palette-for-windows-scrivener/140299>\
**Category:** Scrivener for Windows\
**Tags:** feedback, usage-tips, automation\
**Created:** [April 23, 2024, 8:54pm UTC](https://forum.literatureandlatte.com/t/ahk-palette-for-windows-scrivener/140299 "2024-04-23T20:54:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimRac](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/jimrac/32/16153_2.png) [@JimRac](https://forum.literatureandlatte.com/u/JimRac)\
**Post date:** [April 23, 2024, 8:54pm UTC](https://forum.literatureandlatte.com/t/ahk-palette-for-windows-scrivener/140299/1 "2024-04-23T20:54:14Z")

</div>

Inspired by @fto’s [post](https://forum.literatureandlatte.com/t/keyboard-maestro-palette-with-three-simple-actions-for-scrivener-mac/140267/1), which provides a Keyboard Maestro palette to assist with simple actions in Scrivener, here is an equivalent AutoHotKey (AHK) palette I developed for myself a while ago.

The palette invokes AHK code to automate menu shortcuts that I use all the time. If you have even a minimal coding background, it should be simple to tweak the script to add and remove whatever shortcuts you like.

Pressing F10 launches the palette, which looks likes this:

![image](https://forum.literatureandlatte.com/uploads/default/original/3X/5/b/5b98cfab40ad86570cf81a302de1bcefbcd31dbb.png)

The code is below.

AHK Palette.ahk

```nohighlight
#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 Qt643QWindowIcon

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

;	F10 engages the command palette
f10::

RunWait, AHK Palette_proc.ahk
return

```

AHK Palette\_proc.ahk

```nohighlight
;--------------------------------------------------------------------------
; Auto-Execute section
;--------------------------------------------------------------------------

#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.

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

; Build command palette

Menu, Palette, Add
Menu, Palette, deleteAll

Menu, Palette, Add, &Add to Collection, AddToColl
Menu, Palette, Add, &Bullets, Bullets
Menu, Palette, Add, &Color, Color
Menu, Palette, Add, Complete Doc &Title, Title
Menu, Palette, Add, C&opyHolder, CopyHolder
Menu, Palette, Add, &Highlight, Highlight
Menu, Palette, Add, &New from Template, NewFromTemplate
Menu, Palette, Add, Outliner Selection A&ffects, Affects
Menu, Palette, Add, &Para Spacing, ParaSpacing
Menu, Palette, Add, &QuickRef, QuickRef
Menu, Palette, Add, Re&veal in Binder, Reveal
Menu, Palette, Add, &Revision Mode, Revision
Menu, Palette, Add, &Swap Editors, Swap

; Show command palette

Menu, Palette, Show
ExitApp
return

;--------------------------------------------------------------------------
; Process platette selection
;--------------------------------------------------------------------------

Affects:
Send !n
Send {Down 12}
Send {Enter}
return
;

AddToColl:
Send !d
Send d
return
;

Bullets:
Send !r
Send l
Send {Down 4}
Send {Enter}
return
;

Color:
Send {AppsKey}
Send c
Send c
return
;

CopyHolder:
Send !n
Send o
Send c
return
;

Highlight:
Send {AppsKey}
Send h
return
;

NewFromTemplate:
Send !p
Send w
return
;

ParaSpacing:
Send !r
Send p
Send l
Send {Enter}
WinWait, Line Spacing, , 10
WinActivate, Line Spacing
Send {Enter}
return
;

QuickRef:
Send !n
Send o
Send q
return
;

Reveal:
Send !n
Send {Enter}
return
;

Revision:
Send !r
Send r
Send f
return
;

Swap:
Send !v
Send l
Send w
return
;

Title:
Send !+=
KeyWait, Tab, D, T10
if ErrorLevel ; i.e. it's not blank or zero.
		; MsgBox, error level
		return
	else
		; MsgBox, no error level
		Send ]]
return
;

```

Notes

- Create and store AHK Palette.ahk and AHK Palette\_proc.ahk in the same folder.
- Copy a shortcut to AHK Palette.ahk into your Windows Startup folder.
- The script only works when Scrivener is running.
- For ‘Complete Doc Title’ to work, enable setting File \> Options \> Corrections \> Corrections \> Automatically detect [[document links]].

Let me know if you have any questions.

Best,  
Jim
