Insert AHK Command/Function Parameters (with Search/Auto-Complete)

Discuss features, issues, about Editors for AHK
User avatar
Posts: 6631
Joined: 21 Dec 2014, 02:44

Insert AHK Command/Function Parameters (with Search/Auto-Complete)

06 May 2017, 11:43

This tool provides automatic insertion of the parameter definitions for AutoHotkey's commands, functions, and directives (will be referred to simply as commands for brevity).
  • It will auto-complete the command name using either of two incremental search modes: match from the beginning of the command name or match anywhere within it.
  • A list of available parameter definitions will be displayed. It will insert the parameter list for that command, allowing you to select among the alternatives if multiple are available.
  • It currently works with Notepad++, SciTE4AutoHotkey, AHK Studio, and AutoGUI. It should work with any editor that accepts pasted text and returns caret positions by adding the editor's WinTitle to the ahk_group.
I'd like to acknowledge Helgef's excellent AHK Hotstrings script which provides similar functionality. This tool is presented as an alternative or an addition to it. I can certainly see both being used as they each have their strengths, and either one can be invoked when desired. Many thanks to jeeswg and Helgef for their development of the command/parameters list, which I've made use of here.

I developed this tool so that it would include auto-complete in a parameter insertion tool (I'm too lazy to type long command names) and because the hotstrings-based tool works very slowly in the main place that I use it: in Notepad++ with auto-complete enabled. This is because a hotstring (and Send command) is basically typing out the text, so Notepad++'s auto-complete tries to suggest words for it as it types, causing it to operate very slowly. This tool pastes the text into your editor, making it immediate and eliminating this issue.

  • Press CapsLock to invoke the command/function search, which will match from the start of the names:
  • Alternatively, press Shift + CapsLock so that command/function search will match anywhere:
    (You can of course change CapsLock and +CapsLock to any other hotkeys you wish.)
  • Use up/down arrow keys to navigate the matched entries or keep typing until the desired command is highlighted.
  • Press Enter to insert the command function name and to display its parameter definition(s).
  • If there is more than one parameter definition available, use the up/down arrow keys to select and press Enter to insert the parameters.
  • Press Escape at any time to exit without inserting the selection.
Insert AHK Parameters.ahk
(19.32 KiB) Downloaded 968 times

Alternate version with ToolTips option
As suggested by BoBo, here is an alternate version that allows the parameters to be displayed as a ToolTip rather than insertion into the editor. Select option from tray icon. Initiate as usual and ToolTip will display instead. Press Esc or Exit to dismiss ToolTip.

Download alternate version:
Insert AHK Parameters_tooltip option.ahk
(20.35 KiB) Downloaded 84 times
Last edited by boiler on 09 Jul 2020, 22:40, edited 2 times in total.
Posts: 4479
Joined: 17 Jul 2016, 01:02

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

06 May 2017, 17:43

Very nice! :bravo:
The editbox solution is really smart I think, it solves all problems of tracking what is being typed.

I have worked on a similar script, but that project has spawned so many sidetracks that I'm not sure where it is going now :lol:

Anyways, great job and thanks for sharing.
User avatar
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

07 May 2017, 10:44

Thanks! Glad you like it. I know the feeling about the sidetracks. :D

One of the throw-ins I added was the alternate incremental search mode where it matches anywhere, but I think maybe it should be the primary mode under the main hotkey. Sometimes I remember part of a command's name but not how it starts, like the various trim commands/functions (AutoTrim, LTrim, RTrim StringTrimLeft, etc.).
Posts: 4479
Joined: 17 Jul 2016, 01:02

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

07 May 2017, 11:29

Yes match anywhere is very nice.
It is very easy to modify and add to this script. Five minute effort, here is all gdip_ functions (currently in my user lib)

Code: Select all

Gdip_BitmapFromBRA;(ByRef BRAFromMemIn, File, Alternate=0) 
Gdip_DrawRectangle;(pGraphics, pPen, x, y, w, h) 
Gdip_DrawRoundedRectangle;(pGraphics, pPen, x, y, w, h, r) 
Gdip_DrawEllipse;(pGraphics, pPen, x, y, w, h) 
Gdip_DrawBezier;(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4) 
Gdip_DrawArc;(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle) 
Gdip_DrawPie;(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle) 
Gdip_DrawLine;(pGraphics, pPen, x1, y1, x2, y2) 
Gdip_DrawLines;(pGraphics, pPen, Points) 
Gdip_FillRectangle;(pGraphics, pBrush, x, y, w, h) 
Gdip_FillRoundedRectangle;(pGraphics, pBrush, x, y, w, h, r) 
Gdip_FillPolygon;(pGraphics, pBrush, Points, FillMode=0) 
Gdip_FillPie;(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle) 
Gdip_FillEllipse;(pGraphics, pBrush, x, y, w, h) 
Gdip_FillRegion;(pGraphics, pBrush, Region) 
Gdip_FillPath;(pGraphics, pBrush, Path) 
Gdip_DrawImagePointsRect;(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1) 
Gdip_DrawImage;(pGraphics, pBitmap, dx="", dy="", dw="", dh="", sx="", sy="", sw="", sh="", Matrix=1) 
Gdip_ReleaseDC;(pGraphics, hdc) 
Gdip_GraphicsClear;(pGraphics, ARGB=0x00ffffff) 
Gdip_BlurBitmap;(pBitmap, Blur) 
Gdip_SaveBitmapToFile;(pBitmap, sOutput, Quality=75) 
Gdip_GetPixel;(pBitmap, x, y) 
Gdip_SetPixel;(pBitmap, x, y, ARGB) 
Gdip_GetImageDimensions;(pBitmap, ByRef Width, ByRef Height) 
Gdip_GetDimensions;(pBitmap, ByRef Width, ByRef Height) 
Gdip_BitmapSetResolution;(pBitmap, dpix, dpiy) 
Gdip_CreateBitmapFromFile;(sFile, IconNumber=1, IconSize="") 
Gdip_CreateBitmapFromHBITMAP;(hBitmap, Palette=0) 
Gdip_CreateHBITMAPFromBitmap;(pBitmap, Background=0xffffffff) 
Gdip_CreateBitmap;(Width, Height, Format=0x26200A) 
Gdip_CloneBitmapArea;(pBitmap, x, y, w, h, Format=0x26200A) 
Gdip_CreatePen;(ARGB, w) 
Gdip_CreatePenFromBrush;(pBrush, w) 
Gdip_BrushCreateHatch;(ARGBfront, ARGBback, HatchStyle=0) 
Gdip_CreateTextureBrush;(pBitmap, WrapMode=1, x=0, y=0, w="", h="") 
Gdip_CreateLineBrush;(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1) 
Gdip_CreateLineBrushFromRect;(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1) 
Gdip_TextToGraphics;(pGraphics, Text, Options, Font="Arial", Width="", Height="", Measure=0) 
Gdip_DrawString;(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF) 
Gdip_MeasureString;(pGraphics, sString, hFont, hFormat, ByRef RectF) 
Gdip_SetStringFormatAlign;(hFormat, Align) 
Gdip_StringFormatCreate;(Format=0, Lang=0) 
Gdip_FontCreate;(hFamily, Size, Style=0) 
Gdip_CreateAffineMatrix;(m11, m12, m21, m22, x, y) 
Gdip_AddPathEllipse;(Path, x, y, w, h) 
Gdip_AddPathPolygon;(Path, Points) 
Gdip_SetTextRenderingHint;(pGraphics, RenderingHint) 
Gdip_SetInterpolationMode;(pGraphics, InterpolationMode) 
Gdip_SetSmoothingMode;(pGraphics, SmoothingMode) 
Gdip_SetCompositingMode;(pGraphics, CompositingMode=0) 
Gdip_RotateWorldTransform;(pGraphics, Angle, MatrixOrder=0) 
Gdip_ScaleWorldTransform;(pGraphics, x, y, MatrixOrder=0) 
Gdip_TranslateWorldTransform;(pGraphics, x, y, MatrixOrder=0) 
Gdip_GetRotatedTranslation;(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation) 
Gdip_GetRotatedDimensions;(Width, Height, Angle, ByRef RWidth, ByRef RHeight) 
Gdip_ImageRotateFlip;(pBitmap, RotateFlipType=1) 
Gdip_SetClipRect;(pGraphics, x, y, w, h, CombineMode=0) 
Gdip_SetClipPath;(pGraphics, Path, CombineMode=0) 
Gdip_SetClipRegion;(pGraphics, Region, CombineMode=0) 
Gdip_LockBits;(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a) 
Gdip_UnlockBits;(pBitmap, ByRef BitmapData) 
Gdip_SetLockBitPixel;(ARGB, Scan0, x, y, Stride) 
Gdip_GetLockBitPixel;(Scan0, x, y, Stride) 
Gdip_PixelateBitmap;(pBitmap, ByRef pBitmapOut, BlockSize) 
Gdip_ToARGB;(A, R, G, B) 
Gdip_FromARGB;(ARGB, ByRef A, ByRef R, ByRef G, ByRef B) 
CommandText.= "`n" p2

Sort,CommandText ; I don't know if this is needed, I just guessed.
Paste here:

Code: Select all

CommandText = 
;PASTE here:
The list was generated with this script Insert User Function Definitions -- for Notepad++, specifically see my post :D

Any thought on using the function script for auto-adding functions in current script or something like that? :geek:

User avatar
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

08 May 2017, 20:46

That's a nice addition and a good point in general that anyone can add any library functions to this that they want using your technique. :thumbup:
A couple notes to others looking to do the same:
  • It is important to put the text for your additions in its own continuation section as Helgef did, which is to define a variable whose contents are between its own pair parentheses, then concatenate it to the CommandText variable. This is because there is a limit to how many characters a single continuation section can contain, and the main command/function/directive list is pushing that limit. Per the AHK documentation: "A continuation section cannot produce a line whose total length is greater than 16,383 characters."
  • If the text of what you add includes a ";" character, it will cause a minor problem because I chose that character as a delimiter in the list between the name of the command and its parameters.
Helgef wrote:Any thought on using the function script for auto-adding functions in current script or something like that?
This is a good idea, and I have been thinking it would be nice to combine the two, but I haven't yet put any effort into it yet. The one issue I thought about is that it would only work with editors that show the full path in the window title as Notepad++ so it can find the #Include files, but that's okay. It would be a nice project for a rainy day...
User avatar
Posts: 4480
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

09 May 2017, 01:59

I think Scite4AutoHotkey and AHKStudio both offer a COMObject to get that sort of data.
Recommends AHK Studio

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

09 May 2017, 03:01

Useful - Some thoughts:

* CommandText should be separated from the script in its own file(folder?). That way you can modify the script more easily and exchange update without the need to mess with it.

* You can have multiple CommandTexts files, makes it easy to update the externally and reload the script (external script can reload your script to update it)

* Look at Goto/TillaGoto for some code to "find" functions in the current edited file so they can be added dynamically or on "user activated scan" (could include a "scan project" so it scans all #includes)

* Also here is "quick help in any editor" which could be integrated.

User avatar
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

09 May 2017, 19:31

@nnik: That should come in handy. Thanks for the info.

I considered whether to put the CommandText data in the script file, and I ended up thinking that a single file might make it more convenient for people. I typically lean towards what you recommended. And your suggestion about them possibly being in a separate folder might be better because then it could read any and all files in that folder, making it easier to manage adding library function definitions as Helgef did. Sounds like a worthwhile change in a future update.

I did briefly look at GotoTilla and TillaGoto but didn't end up reverse engineering their code for that part (although I did look at what they did for their combined edit box/list box). I may revisit them if I do tackle the task of integrating user functions into this, although I may just use what I already do in my other script for that at first since I primarily use Notepad++ at the moment.

Thanks for the link to the context-sensitive help. I have been using Rajat's version of that. I can see how something like that might be worthwhile to tie into this, although I find it works fine as a separate script. I suppose the main reason to do it is to reduce the number of scripts you have running.
Posts: 793
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

02 Jan 2020, 16:18


I took the liberty to convert your script into a class and extended the AHK Items to directives, keywords, keys, methods and properties and flow commands.
It works similar to your original script. There are a few differences.
Capslock always shows the edit control. with Shift+Capslock the algorithm can be changed while typing.

It works in general. But I have a problem with the escape sequences.
For some predefined function bodies, e.g. gGuiControlLabel(CtrlHwnd, GuiEvent, EventInfo, ErrLevel:="")`n{`n`t|`b|`r}
, and flow of control commands, e.g. Loop [, Count]`n{`n |`n}, I have set `n and `t.
For some reason they do not expand to Enter and Tab when send to Notepad++ or Notepad.
It works when I use the Send command on a hotkey or in a function. But it doesn't work with this class. Don't know why. Any hint appreciated.
(10.44 KiB) Downloaded 139 times
User avatar
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

02 Jan 2020, 23:09

It looks like a very nice update and extension. Thanks for sharing it.

It may not be expanding the `n and `t because of the way the original uses a paste (sending text using Control+v) rather than using Send. See the function named Paste(). (I did this to avoid the issues with Notepad++'s built-in autocomplete trying to expand the text as it is sent if done using the Send command.) I tried seeing if there was an easy fix to the `n and `t issue by changing the send method in the Paste() function to Send (or alternatively SendInput) instead of Control+v, but then the editor was losing focus and causing issues for some reason. It doesn't do that when I change my original version to use Send instead of Control+v, so it seems to be related to how the class is using it, but I can't see why at this point. I imagine it can be resolved, though.
Posts: 793
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

03 Jan 2020, 02:52

I will have to resolve the escape sequences in the code. They are not resolved because they are read from file. In your original Script thy were script literal and than they are resolved automatically....
Or I’ll include the files.
User avatar
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Insert AHK Command/Function Parameters (with Search/Auto-Complete)

09 Jul 2020, 22:30

Added alternate version to initial post that allows for an option to show parameters as ToolTips instead.

Return to “Editors”

Who is online

Users browsing this forum: No registered users and 3 guests