Skip to content

Instantly share code, notes, and snippets.

@db93n2
db93n2 / media keys.ahk
Last active October 24, 2017 14:24
▶️ (autohotkey) - turn any key into a media key, then double tap to send the original key
home::
goTo, media_prev
return
end::
goTo, media_play_pause
return
insert::
goTo, media_next
@db93n2
db93n2 / times tables.md
Created January 6, 2017 00:03
(autohotkey) - 2 to 20 times tables as hotstrings

times tables

example key sequence:   2 t 2 = space

2t2=    --->   4

12t11=    --->   132

@db93n2
db93n2 / double_tap.ahk
Last active September 21, 2020 11:00
(autohotkey) - double tap function to send a hotkey or label
double_tap(single_tap, double_tap, tap_time="T.2") {
key := LTrim(a_thisHotkey, "~$*")
key := regExReplace(key, "[\Q^!+#\E]") ; remove modifiers
keyWait, % key
keyWait, % key, D %tap_time%
if (errorLevel)
sub_send(single_tap)
else sub_send(double_tap)
}
@db93n2
db93n2 / days_in_month.ahk
Last active November 7, 2017 06:53
(autohotkey) - find how many days are in a given month
days_in_month(date="") {
date := (date = "") ? (a_now) : (date)
formatTime, year, % date, yyyy
formatTime, month, % date, MM
month += 1 ; goto next month
if (month > 12)
year += 1, month := 1 ; goto next year, reset month
month := (month < 10) ? (0 . month) : (month) ; 0 to 01
new_date := year . month
new_date += -1, days ; minus 1 day
@db93n2
db93n2 / between.ahk
Last active January 24, 2017 10:22
(autohotkey) - split between two characters/words/sentences
between(string, left, right) {
if (strLen(left) > 1) ;# if its a word or sentence
{
string := strReplace(string, left, "¢") ; replace with symbol
left := "¢" ; set new deliminator
}
if (strLen(right) > 1)
{
string := strReplace(string, right, "¢")
right := "¢"
@db93n2
db93n2 / clipboard.ahk
Last active July 27, 2023 16:23
(autohotkey) - one line clipboard commands
clipboard(string="") {
static clipboard_r
if (string = "/save")
clipboard_r := clipboardAll
else if (string = "/restore")
{
clipboard := clipboard_r
clipboard_r := ""
}
@db93n2
db93n2 / counter_reset.ahk
Last active November 7, 2017 06:48
(autohotkey) - keep a number within a certain range when adding/subtracting
counter_reset(number, min, max) {
if (number < min)
return max
else if (number > max)
return min
else return number
}
/*
@db93n2
db93n2 / file properties.ahk
Last active November 26, 2021 19:52
(autohotkey) - open properties for the selected file (and use "run" if the hotkey didnt send)
#ifWinActive ahk_class CabinetWClass
^+p::goSub, file_properties
#ifWinActive
file_properties:
revert_clipboard := clipboardAll
clipboard =
send ^{c}
clipWait, 0.6
@db93n2
db93n2 / sublime goto error.ahk
Last active November 7, 2017 07:01
(autohotkey) - goto line and highlight the error text (autohotkey only)
/*
[script info]
version = 3.4
description = goto line and highlight the error text (autohotkey only)
author = davebrny
source = https://gist.github.com/davebrny/ff6a00e55d9d81e4bea9fe1d852d84a9
*/
#noEnv
#persistent
@db93n2
db93n2 / close ahk errors.ahk
Last active January 26, 2017 17:54
(autohotkey) - save to close any ahk error windows
#if winActive("ahk_class Notepad")
or winActive("ahk_class Notepad++")
or winActive("ahk_exe sublime_text.exe")
~^s::goSub, close_ahk_errors ; ctrl + s (~pass through)
#if