Skip to content

Instantly share code, notes, and snippets.

@davebrny
davebrny / truncate.ahk
Created November 15, 2017 13:23
(autohotkey) - truncate a string
truncate(string, at, divider=" . . . . ") {
if (strLen(string) > at)
string := subStr(string, 1, at/2) . divider . subStr(string, -at/2)
return string
}
@davebrny
davebrny / onTop.ahk
Last active January 6, 2021 22:41
🎩 (autohotkey) - manage 'always on top' windows from a context menu
#noEnv
#singleInstance, force
return ; end of auto-execute
#space::goSub, onTop_menu ; show menu
#!space::goSub, toggle_onTop ; toggle the active window
^#!space::goSub, minimise_all_onTop
@davebrny
davebrny / lightshot+.ahk
Last active October 25, 2023 13:06
(autohotkey) - improvements for lightshot (screenshot tool)
/*
[folders]
folder_1=
folder_2=
folder_3=
[settings]
prefix = LS_
time_format = yyyyMMddhhmmss
fullscreen_hotkey =
@davebrny
davebrny / clear_split.ahk
Last active November 13, 2017 14:04
(autohotkey) - clear a split array/object array
clear_split(byRef name) {
loop, % isObject(name) ? name.maxIndex() : %name%0
{
%name%%a_index% := ""
name[a_index] := ""
}
%name%0 := ""
name := ""
}
@davebrny
davebrny / run_at_startup.ahk
Created November 13, 2017 12:13
(autohotkey) - tray option to run your scripts at startup
run_at_startup(seperator="", menu_name="tray") {
global ras_shortcut, ras_menu
ras_menu := menu_name
if (seperator = "1") or (seperator = "3")
menu, % ras_menu, add,
menu, % ras_menu, add, Run At Startup, run_at_startup
splitPath, a_scriptFullPath, , , , script_name
ras_shortcut := a_startup "\" script_name ".lnk"
@davebrny
davebrny / get_selected.ahk
Created November 13, 2017 10:37
(autohotkey) - gets selected text (or path of selected file/folder)
get_selected(wait_time="0.3") {
revert_clipboard := clipboardAll
clipboard := "" ; clear first
send ^{c}
clipWait, % wait_time
selected := clipboard
clipboard := revert_clipboard
return selected
@davebrny
davebrny / quote.ahk
Created November 13, 2017 10:08
(autohotkey) - wrap a string in quotes
quote(string) {
return """" string """"
}
@davebrny
davebrny / sp.ahk
Last active November 14, 2017 13:58
(autohotkey) - return or add a singular/plural suffix
sp(number, string="", suffix="s") {
if (string)
string := number " " string
if (number = 1)
return string . ""
else return string . suffix
}
@davebrny
davebrny / txt.swap.ahk
Last active January 11, 2024 07:23
(autohotkey) - swap text at a certain character or word, interactively
#noEnv
#singleInstance, force
sendMode input
return ; end of auto-execute ---------------------------------------------------
!s:: goSub, text_swap
!+s::goSub, repeat_last_swap
; !+s::goSub, repeat_last_swap_interactive
@davebrny
davebrny / reloadr.ahk
Last active April 15, 2023 20:29
🚚 (autohotkey) - reload running scripts from a context menu
/*
[script info]
version = 0.8
description = reload running scripts from a context menu
author = davebrny
source = https://gist.github.com/davebrny/4f14e1edb4fac2fc2459c3d87fa537f7
[settings]
hotkey_menu = ^+`
hotkey_default = ^`