The example below makes Ctrl+⇧ Shift+Q replace selected text in an editor with a quoted version of that text. It illustrates the use of functions, arguments and default argument values.

    1. ^+q::QuoteSelection() ; Ctrl+Shift+Q
    2. QuoteSelection()
    3. {
    4. selection:= GetSelection() ; Get selected text.
    5. PasteText(Quote(selection)) ; Quote the text and paste it back.
    6. }
    7. GetSelection(timeoutSeconds:= 0.5)
    8. {
    9. Clipboard:= "" ; Clear clipboard for ClipWait to function.
    10. Send ^c ; Send Ctrl+C to get selection on clipboard.
    11. ClipWait %timeoutSeconds% ; Wait for the copied text to arrive at the clipboard.
    12. return Clipboard
    13. }
    14. PasteText(s)
    15. {
    16. Clipboard:=s ; Put the text on the clipboard.
    17. Send ^v ; Paste the text with Ctrl+V.
    18. }
    19. Quote(s)
    20. {
    21. return """" . s . """"
    22. }