AutoHotkey
AutoHotkey (AHK) is a scripting language for the
automation of tasks with the use of hotkeys. AHK can automate graphical
applications by simulating clicks and keystrokes, and uses a simple, flexible,
and easy to learn syntax. This makes it a great tool to automate all kinds of
tasks in any Windows application. It is available only on the Windows operating
system. From their home page, follow the download link (Download Current
Version), and then install the downloaded .exe
file. The full AHK
documentation is also
available on their website.
Please know, you do not need this program for ecoacoustic analysis or workflows. However, if you are performing a repetitive task, such as annotating a large number of sound files, AHK scripts might be able to make your life a little bit easier. This help page is focused on a specific example of using AHK with the Raven Pro software. Previous versions of Raven had few inbuilt shortcut keys, and required a lot of clicking. This functionality has improved with recent versions, so you may have no need for AHK. However, if you want to automate button presses for which no shortcut key exists, or use your own custom shortcut keys, then AHK is still a good choice. Familiarity with AHK could also help you create shortcuts and hotkeys for other parts of your workflow.
Setup and example script #
If you haven’t already installed the AHK program, do so now. Then, you may
download the example AHK script available
here, by
downloading the file as a zip with the Download Zip
button, or copying the
script contents into a blank Visual Studio Code file. The script is also embedded at the
bottom of this help page. After downloading or copying the
script contents, make sure your file is saved with the .ahk
extension.
First use #
Right click on the downloaded AHK file, and Open with
an editor such as Visual
Studio Code. Have a read through the information in the file, and make any
changes if you want to. Next, you can double click on the file in File Explorer
to run the script, and check your taskbar icons to make sure the
script is successfully running.
Usage #
hotkey | action |
---|---|
ctrl + mouse up |
zoom in |
ctrl + mouse down |
zoom out |
F1 |
zoom to all |
F2 |
zoom to selection |
F3 |
move to next selection |
With these hotkeys, working through a large number of annotations is easier.
Navigate to the next selection with F3
, press F2
to zoom into that
selection, make adjustments if necessary, and then move to the next selection
with F3
again. Press F1
at any time to zoom out for a big picture view of
the file, and then F3
to zoom back in to the current selection.
Note:
This script works by moving your mouse to predefined positions, clicking a button, and then returning your mouse. This has been tested this with raven 1.6.1, with the default window arrangement. If the hotkeys do not work as expected, or click different things, or nothing at all, then perhaps your window arrangement or arrangement of icons is different. In this case, you will need to modify theX
andY
settings in the.ahk
file. You can find the values that match your window setup, by using the Window Spy tool that comes with AHK. Otherwise, check back here in the future for a ready made 1.6.4 version!
Customisation #
Feel free to customise the hotkeys in this file, and experiment with making your own hotkeys!
It is simple to change a hotkey. For example, the default hotkey for move to
next selection is currently F3::
. You can edit the content to the left of the
::
to reflect your desired hotkey. If you change this line to Right::
, then
the hotkey to move to next selection would be the right arrow key instead of
F3
. For the full keylist, see this
document.
Note:
If you make changes to your AHK script (using a text editor), then you will have to save the script, and re-run it, before the changes take effect.
AHK script #
;; Raven Shortcuts | |
;; https://github.com/andrew-1234 | |
;; Intro: | |
;; install AHK if you haven't already | |
;; save this script, make sure it has extension .ahk | |
;; double click to run the script. you should see it running in your task bar | |
;; icons | |
;; Usage note: this script works by moving your mouse to predefined positions, | |
;; clicking a button, and then returning your mouse. | |
;; i have tested this with raven 1.6.1, with the default window arrangement. | |
;; if the hotkeys do not work as expected, or click different things, or nothing, | |
;; then perhaps your window arrangement / arrangement of icons is different. | |
;; in this case, you will need to modify the X and Y settings in this file. | |
;; you can find those values using the Window Spy tool that comes with AHK | |
;; Customisation: | |
;; Change any of the hotkeys to whatever you like | |
;; E.g. F3:: in this script moves to next selection | |
;; If you change this to Right:: | |
;; Then the right arrow key would be used to move to next selection instead. | |
;; See the full keylist here: https://www.autohotkey.com/docs/KeyList.htm | |
;; If you do make changes to this script (using a text editor), then you will have to | |
;; save the script, and re-run it, before the change take effect. | |
;;============================================================================== | |
;; General script settings | |
#NoEnv | |
SendMode Input | |
SetWorkingDir %A_ScriptDir% | |
#SingleInstance, force | |
;;============================================================================== | |
;; Set the script to only work when Raven is active | |
;; these hotkeys will only work when a Raven Pro window is detected | |
SetTitleMatchMode, 2 | |
#IfWinActive, Raven Pro | |
;;============================================================================== | |
;; Zoom in and out of sound when holding down ctrl and using the scroll wheel | |
;; Specifying ctrl means you preserve ability to scroll the selection table | |
^WheelUp:: ;; Zoom in when pressing ctrl + wheel up. | |
;; the ^ means ctrl key, ^ plus mouse scroll = execute this action | |
Sleep, 5 | |
MouseGetPos, StartX, StartY ;; saves the current mouse position coordinates | |
CoordMode, Mouse, Window ;; use window mode setting, | |
; the x and y coordinates that are entered will be relative to the current | |
; working window (e.g. Raven) therefore if you resize raven or use different | |
; monitor size (laptop vs desktop), the script should still work | |
x := 299 | |
y := 101 | |
;; these are the x and y coordinates of the zoom in button in raven. if the | |
;; button is in a different position on your raven version, you can adjust these | |
;; coordinates using window spy which comes with AHK | |
Click %x% %Y% | |
Click %x% %Y% ;; I have mine set to click twice | |
MouseMove, StartX, StartY ;; this moves mouse back to starting position | |
return | |
^WheelDown:: ;; Zoom out | |
Sleep,5 | |
MouseGetPos, StartX, StartY | |
CoordMode, Mouse, Window | |
x := 326 | |
y := 102 | |
Click %x% %Y% | |
Click %x% %Y% | |
MouseMove, StartX, StartY | |
return | |
;;============================================================================== | |
;; Navigating through selections | |
F1:: ;; zoom to all | |
Sleep,100 | |
MouseGetPos, StartX, StartY | |
CoordMode, Mouse, Window | |
x := 271 | |
y := 102 | |
Click %x% %Y% | |
MouseMove, StartX, StartY | |
return | |
F2:: ;; zoom to selection | |
Sleep,100 | |
MouseGetPos, StartX, StartY | |
CoordMode, Mouse, Window | |
x := 244 | |
y := 102 | |
Click %x% %Y% | |
MouseMove, StartX, StartY | |
return | |
F3:: ;; activate next selection | |
Sleep,100 | |
MouseGetPos, StartX, StartY | |
CoordMode, Mouse, Window | |
x := 646 | |
y := 102 | |
Click %x% %Y% | |
MouseMove, StartX, StartY | |
return |