Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active April 2, 2023 04:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davebrny/101683d4b0277c9d4dd0b13ba82a4bba to your computer and use it in GitHub Desktop.
Save davebrny/101683d4b0277c9d4dd0b13ba82a4bba to your computer and use it in GitHub Desktop.
(autohotkey) - switch between the various time ranges (hour, day, week, month, year) πŸ”Ž
#if WinActive("ahk_class Chrome_WidgetWin_1", , "ahk_class #32770")
or WinActive("ahk_class MozillaWindowClass", , "ahk_class #32770")
^+l::goSub, google_time_range
#if
google_time_range:
send ^{l}
input, key_pressed, L1 T3, {0}{h}{d}{w}{m}{y}{esc}
if errorLevel contains escape,max,timeout
return ; #####################################
new_range := "qdr:" . strReplace(errorLevel, "EndKey:", "")
stringLower, new_range, new_range
revert_clipboard := clipboardAll
clipboard =
send ^{l}^{c}
clipWait, 0.3
if clipboard not contains www.google.
return ; ########################
if inStr(clipboard, "qdr:")
{
loop, parse, % "0|h|d|w|m|y", |
stringReplace, clipboard, clipboard, % "qdr:" a_loopField, % new_range, all
}
else clipboard .= "&tbs=" new_range
send ^{l}^{v}{enter}
clipboard := revert_clipboard
return
/*
[script info]
version = 1
description = switch between the various time ranges (hour, day, week, month, year)
author = davebrny
source = https://gist.github.com/davebrny/101683d4b0277c9d4dd0b13ba82a4bba
*/
@davebrny
Copy link
Author

this uses a two stage hotkey to switch between the time ranges

  • first use Β  ctrlshift + l Β  (the L key)

  • then press one of the following keys: h d w m y or 0

h = hour
d = day
w = week
m = month
y = year
0 = clear / reset

Β 

- the two stage hotkey will timeout after 3 seconds if the second key isnt pressed.
- the escape can be used to cancel if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment