Last active
February 12, 2017 22:42
-
-
Save davebrny/3ac1f359d3d033cfe3e072446cb3c401 to your computer and use it in GitHub Desktop.
(autohotkey) - search the selected word in the local autohotkey .chm help file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ahk_help(search_term="") { | |
static ahk_dir | |
if (search_term = "") ; check for a selection | |
{ | |
revert_clipboard := clipboardAll | |
clipboard = | |
send ^{c} | |
clipWait, 0.3 | |
search_term := clipboard | |
clipboard := revert_clipboard | |
} | |
if winExist("ahk_class HH Parent") | |
winActivate, ahk_class HH Parent | |
else | |
{ | |
if (ahk_dir = "") | |
regRead, ahk_dir, HKLM, SOFTWARE\AutoHotkey, installDir | |
run, % ahk_dir "\AutoHotkey.chm" | |
winWaitActive, ahk_class HH Parent | |
} | |
if (search_term != "") and (!inStr(search_term, "`n")) | |
{ | |
controlGetFocus, active_control, a | |
if !inStr(active_control, "edit") | |
sendMessage, 0x1330, 0, , SysTabControl321, a ; focus on contents tab to reset the control focus (0x1330 = TCM_SETCURFOCUS) | |
sendMessage, 0x1330, 1, , SysTabControl321, a ; focus on index tab | |
controlGetFocus, active_control, a ; (the index edit changes depending on what tabs have been viewed) | |
controlSetText, % active_control, , a | |
sendRaw %search_term% ; send raw in case # is at start of the selection, e.g. #noEnv | |
send {enter} | |
} | |
} | |
; set SetTitleMatchMode to "2" to detect ".ahk" in the window title | |
#if winActive(".ahk ahk_exe sublime_text.exe") | |
or winActive("AHK Studio - ahk_class AutoHotkeyGUI") | |
or winActive(".ahk ahk_class Notepad++") | |
or winActive(".ahk ahk_class Notepad") | |
F1::ahk_help() | |
#if | |
/* | |
[script info] | |
version = 1.4 | |
description = search the selected word in the local autohotkey.chm help file | |
author = davebrny | |
source = https://gist.github.com/davebrny/3ac1f359d3d033cfe3e072446cb3c401 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ahk help
F1
will open the local autohotkey.chm help filefor ".ahk" to be detected in the window title,
SetTitleMatchMode
needs to be set to "2" in the auto-execute section of your script