Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active February 12, 2017 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebrny/3ac1f359d3d033cfe3e072446cb3c401 to your computer and use it in GitHub Desktop.
Save davebrny/3ac1f359d3d033cfe3e072446cb3c401 to your computer and use it in GitHub Desktop.
(autohotkey) - search the selected word in the local autohotkey .chm help file
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
*/
@davebrny
Copy link
Author

ahk help

  • if the active editor window contains ".ahk" in the title then F1 will open the local autohotkey.chm help file
  • if a word is selected then it will be entered into the search box

 

for ".ahk" to be detected in the window title, SetTitleMatchMode needs to be set to "2" in the auto-execute section of your script

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