AutocompleteEditorText - using text in editor

Post your working scripts, libraries and tools
brutus_skywalker
Posts: 142
Joined: 24 Dec 2016, 13:16
Location: Antarctica

AutocompleteEditorText - using text in editor

13 May 2018, 04:16

You know how notepad++ can autocomplete text using other text on the page, this script does exactly the same thing,except across multiple editors,though i 'wrote' a lot of it for CodeQuickTester because it's just awesome.

Based on variations on THIS post of rajat's Intellisense script modifications.

; DOUBLE Press 1 to 0 keys to autocomplete the word upon suggestion
; (0 will match suggestion 10)

Will post list-box version without number selection once i refine it.

EDIT: 2018-05-17_07(50)[06]
    Better performance, reliability and compatibility with an additional edit control(Edit3 controls).

EDIT: 2018-05-23_02(11)[58]
    Minor optimizations & refactoring, put() now adds space after auto-completion, muscle memory made me think it did,turns out i was pressing space not the dame script...

Code: [Select all] [Expand] [Download] (AutocompleteEditorText.ahk)GeSHi © Codebox Plus

Last edited by brutus_skywalker on 22 May 2018, 18:34, edited 5 times in total.
Outsourcing Clicks & Presses Since 2004.
LarryC
Posts: 22
Joined: 30 Sep 2013, 12:14

Re: AutocompleteEditorText - using text in editor

13 May 2018, 13:13

I read this twice but still cannot find how to insert an offered word other than a statement saying to press the corresponding number key. Didn't work, but does work if double pressed the corresponding number.
brutus_skywalker
Posts: 142
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: AutocompleteEditorText - using text in editor

13 May 2018, 23:40

LarryC wrote:I read this twice but still cannot find how to insert an offered word other than a statement saying to press the corresponding number key. Didn't work, but does work if double pressed the corresponding number.


YUP. That was bad instruction on my part. Fixed it. Double Press Number Keys.
Outsourcing Clicks & Presses Since 2004.
A_AhkUser
Posts: 765
Joined: 06 Mar 2017, 16:18
Location: France

Re: AutocompleteEditorText - using text in editor

21 May 2018, 13:56

brutus_skywalker wrote:^If AnyOne can make a listview alternative to this method of selection,by all means...HELP :headwall: ...


A owned GUI endowed with the WS_EX_CLICKTHROUGH (or WS_EX_NOACTIVATE) extended style, and shown using the NA option is functionally equivalent in many respects to a tooltip:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

brutus_skywalker
Posts: 142
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: AutocompleteEditorText - using text in editor

22 May 2018, 05:03

@A_AhkUser


Thanks much,a hell of a nudge in the right direction,appreciate it. Just the example I needed to wrap my head round it. ;)
Outsourcing Clicks & Presses Since 2004.
brutus_skywalker
Posts: 142
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: AutocompleteEditorText - using text in editor

22 May 2018, 18:06

@A_AhkUser


So i more or less get list boxes now,i never got them because i never really tried,it seems...

However i don't care to reinvent the wheel, so i used your library and the attach example as a starting point for a new version below, and it does not seem to want to work with anything but an edit1 control and downright goes crazy with scintilla controls, care to enlighten me as to what i'm doing wrong. Works brilliantly with edit1 controls though.

Code: [Select all] [Expand] [Download] (AutocompleteEditorText (eAutocomplete).ahk)GeSHi © Codebox Plus

Outsourcing Clicks & Presses Since 2004.
A_AhkUser
Posts: 765
Joined: 06 Mar 2017, 16:18
Location: France

Re: AutocompleteEditorText - using text in editor

Yesterday, 21:03

brutus_skywalker wrote:However i don't care to reinvent the wheel, so i used your library and the attach example as a starting point for a new version below, and it does not seem to want to work with anything but an edit1 control and downright goes crazy with scintilla controls, care to enlighten me as to what i'm doing wrong. Works brilliantly with edit1 controls though.


I'm glad you give a chance to the library... but is intended to work only with edit control... - hence the 'e' in eAutocomplete. The class internally relies, among other things, on messages (to set/retrieve the selection in the control, for example) which are specific to edit/richedit controls; hence it goes crazy with - the very specific - scintilla control (btw your code has the virtue to implicitly points out that the class probably needs a control class validator before even a 'control class dispatcher' like the one in your winChanged subroutine). Practically, it means the class will work on paper with both edit and combobox controls, since these latter have an embedded (child) edit control - on paper: I didn't test with combobox controls (btw, in this case it might be more relevant, depending on goals, to use cbAutocomplete by Pulover). Simply, I had not originally take into consideration other kind of control and the script reflects it by its limitations.
That's also the reason why I posted with true peace of mind the eAutocomplete class a few hours after your autocomplete script: to some extent, they share the same goals but yours has the undeniable and specific advantage to work with other kind of controls.

However, I really like how you make the best of the class by attaching dynamically compatible controls and, more specifically, the idea to dynamically set the source depending on the active window. This could actually be tremendously useful when using multiple keyboard layouts and/or various registers of language depending on the active application/web page. This is very interesting. In any event, it makes me want to have a support for other kind of controls. It might be at least possible to add - even in the form of a new library - a full support for richedit control (e.g. word) and textarea html element (in an embedded browser). I shall take it into consideration.

On a side note, note that:

Code: [Select all] [Download] GeSHi © Codebox Plus

A := eAutocomplete.attach(WinExist(), eHwnd)

does not implictly remove the event hook function nor dispose the previous instance since each instance set circular references; alternatively, you might consider to dispose the previous instance before anew calling the attach method in order to update the host edit control.

Thanks for sharing this implementation, really, much appreciated.

P.S.: To which application(s) TConTEXTSynEdit1 belongs?

Return to “Scripts and Functions”

Who is online

Users browsing this forum: arcticir, kunkel321 and 10 guests