Jump to content
Sign in to follow this  
PhoenixXL

Predict Text for a RichEdit Control _RichEditPredictText.au3 (UDF)

Recommended Posts

PhoenixXL

Rich-Edit Predict Text UDF

Working

It sub classes the rich-edit control and matches the current word through the Database

& sets selection in accordance.

For Edit Controls look

Functions

  • Predicts Text from an User-Defined Database.
  • Sets the Predicted Text when Enter is pressed.
  • Pressing Backspace deletes the previously typed character.
  • Support Editing, Overwriting, Updating, Deleting the Database.
  • Has the Feature to add New words the user types in the control, to the Database.
  • Supports Sensitive and In-Sensitive Prediction.
  • Currently Supports Auto-completion only.
  • Rich Edit Controls only supported
Future Updates
  • ​Support Auto-suggestion.
Note That if you set a Password Char for the Edit Box the Prediction will automatically get Unregistered.

This UDF requires Beta Release 3.3.9.4++ [beta-Oct-2012]

Index

; #CURRENT# =====================================================================================================================
;_RegisterPrediction
;_UpdatePredictList
;_UnRegisterPrediction
;_RegisterListingSpaceWords
;_RegisterListingNewWords
;_GetSelectedText
;_GetListCount
;_GetCurrentWord
;_GetCaretOffset
; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================
;_New_WndProc
; AddToArray
; MakeArray
;_RichEdit_SubClass
;_AutoExit
;_PredictText
;_PredictSpaceText
;_SetSelection
;_MatchString
;_CtrlSetStyle
;_CtrlGetStyle
;_RemoveBit
; ===============================================================================================================================

Please Notify for any other Updates and Bugs. :graduated:

Change-log

v1.0 - First Release

v1.1 - Fixed a bug.

RichEditPredictText [uDF] v1.1

v1.1 RichEditPredictText UDF.7z

Previous Downloads : 80

Regards

Phoenix XL

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
Danyfirex

thank you for updating. it's very usefull. I'll try out. regards

Share this post


Link to post
Share on other sites
initspawn

This UDF is great! It is so easy to use. Thank you for sharing. I am try to change one thing...after you press enter to accept the predicted text the cursor goes to the end of the the RichEdit control. Any idea how to make it go to the end of the predicted text instead?

Thanks.

Share this post


Link to post
Share on other sites
PhoenixXL

The bug has been fixed. Check v1.1

Regards :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
tonyatcodeleakers

Odd, im on the current beta release and when using this outside of the examples instead of highlighting the suggestion and allowing you to hit enter to confirm, it automatically applies it.

And because i know someone will ask i did add #include-once

Edited by tonyatcodeleakers

Share this post


Link to post
Share on other sites
PhoenixXL

Can you please post the script.


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
tonyatcodeleakers

Can you please post the script.

IL pm you the source.

Share this post


Link to post
Share on other sites
PhoenixXL

I don't find any errors in the working of the UDF

#include-once
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIRichEdit.au3>
#include <GUIEdit.au3>
#include <GuiMenu.au3>
#include <GuiListBox.au3>
#include <Array.au3>
#include 'RichEditPredictText.au3'

Global $background, $fontsize, $fontname, $background2
Global $aMarquee[8]
Global $_Words2[3] = ['thread', 'level', 'self']
$sMsg = "This tool was coded and compiled" & @CRLF & @CRLF
$sMsg &= "By Tony@codeleakers" & @CRLF & "Version: 4.0"
$main = GUICreate("Tonys Script Editor", 800, 600, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
GUISetBkColor($background2)
$menu1 = GUICtrlCreateMenu("File")
$menu1item1 = GUICtrlCreateMenuItem("Save", $menu1)
$menu1item3 = GUICtrlCreateMenuItem("Open", $menu1)
$menu1item2 = GUICtrlCreateMenuItem("Exit", $menu1)
$menu2 = GUICtrlCreateMenu("Edit")
$menu2item1 = GUICtrlCreateMenuItem("Undo", $menu2)
$menu2item2 = GUICtrlCreateMenuItem("Redo", $menu2)
$menu2item3 = GUICtrlCreateMenuItem("Select All", $menu2)
$menu2item4 = GUICtrlCreateMenuItem("Copy", $menu2)
$menu2item5 = GUICtrlCreateMenuItem("Cut", $menu2)
$menu2item6 = GUICtrlCreateMenuItem("Paste", $menu2)
$menu3 = GUICtrlCreateMenu("Options")
$menu3item1 = GUICtrlCreateMenuItem("Settings", $menu3)
$ftp = GUICtrlCreateMenuItem("Check Syntax (GSC)", $menu3)
$ftp3 = GUICtrlCreateMenuItem("Upload to FTP", $menu3)
$menu4 = GUICtrlCreateMenu("Scripts")
$menu4item1 = GUICtrlCreateMenuItem("Dvar", $menu4)
$menu4item2 = GUICtrlCreateMenuItem("Give Weapon", $menu4)
$menu4item3 = GUICtrlCreateMenuItem("iprintBold", $menu4)
$menu4item4 = GUICtrlCreateMenuItem("Spawn Crate", $menu4)
$menu4item5 = GUICtrlCreateMenuItem("Spawn controllable Sentry", $menu4)
$edit = _GUICtrlRichEdit_Create($main, "", 5, 5, 790, 450, BitOR($ES_AUTOHSCROLL, $ES_AUTOVSCROLL, $WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE))
_WinAPI_SetFont($edit, _WinAPI_CreateFont(16, 0, 0, 0, 500, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, "Courier New"))
_GUICtrlRichEdit_SetBkColor($edit, $background)
_RegisterPrediction($edit, $_Words2, Default, 0)

GUISetState()

While GUIGetMsg() <> -3
Sleep(10)
WEnd
_GUICtrlRichEdit_Destroy($edit)

The text is appended with selection and is deselected upon pressing ENTER.

P.S. You should post the problems in the topic itself so that anybody else facing the same problem can take help

Regards :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
tonyatcodeleakers

I don't find any errors in the working of the UDF

#include-once
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIRichEdit.au3>
#include <GUIEdit.au3>
#include <GuiMenu.au3>
#include <GuiListBox.au3>
#include <Array.au3>
#include 'RichEditPredictText.au3'

Global $background, $fontsize, $fontname, $background2
Global $aMarquee[8]
Global $_Words2[3] = ['thread', 'level', 'self']
$sMsg = "This tool was coded and compiled" & @CRLF & @CRLF
$sMsg &= "By Tony@codeleakers" & @CRLF & "Version: 4.0"
$main = GUICreate("Tonys Script Editor", 800, 600, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
GUISetBkColor($background2)
$menu1 = GUICtrlCreateMenu("File")
$menu1item1 = GUICtrlCreateMenuItem("Save", $menu1)
$menu1item3 = GUICtrlCreateMenuItem("Open", $menu1)
$menu1item2 = GUICtrlCreateMenuItem("Exit", $menu1)
$menu2 = GUICtrlCreateMenu("Edit")
$menu2item1 = GUICtrlCreateMenuItem("Undo", $menu2)
$menu2item2 = GUICtrlCreateMenuItem("Redo", $menu2)
$menu2item3 = GUICtrlCreateMenuItem("Select All", $menu2)
$menu2item4 = GUICtrlCreateMenuItem("Copy", $menu2)
$menu2item5 = GUICtrlCreateMenuItem("Cut", $menu2)
$menu2item6 = GUICtrlCreateMenuItem("Paste", $menu2)
$menu3 = GUICtrlCreateMenu("Options")
$menu3item1 = GUICtrlCreateMenuItem("Settings", $menu3)
$ftp = GUICtrlCreateMenuItem("Check Syntax (GSC)", $menu3)
$ftp3 = GUICtrlCreateMenuItem("Upload to FTP", $menu3)
$menu4 = GUICtrlCreateMenu("Scripts")
$menu4item1 = GUICtrlCreateMenuItem("Dvar", $menu4)
$menu4item2 = GUICtrlCreateMenuItem("Give Weapon", $menu4)
$menu4item3 = GUICtrlCreateMenuItem("iprintBold", $menu4)
$menu4item4 = GUICtrlCreateMenuItem("Spawn Crate", $menu4)
$menu4item5 = GUICtrlCreateMenuItem("Spawn controllable Sentry", $menu4)
$edit = _GUICtrlRichEdit_Create($main, "", 5, 5, 790, 450, BitOR($ES_AUTOHSCROLL, $ES_AUTOVSCROLL, $WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE))
_WinAPI_SetFont($edit, _WinAPI_CreateFont(16, 0, 0, 0, 500, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, "Courier New"))
_GUICtrlRichEdit_SetBkColor($edit, $background)
_RegisterPrediction($edit, $_Words2, Default, 0)

GUISetState()

While GUIGetMsg() <> -3
Sleep(10)
WEnd
_GUICtrlRichEdit_Destroy($edit)

The text is appended with selection and is deselected upon pressing ENTER.

P.S. You should post the problems in the topic itself so that anybody else facing the same problem can take help

Regards :)

will do, and the issue is it doesn't highlight but instead automatically applies the text.

Share this post


Link to post
Share on other sites
PhoenixXL

will do, and the issue is it doesn't highlight but instead automatically applies the text.

The text that is appended is selected so anything you type further will replace the appended text with the new one, that's how it works.

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • careca
      By careca
      Here's my take on an auto completer, work in progress so don't be too harsh with me.
      The idea  is that after a spacebar press, it learns the word that was previously written, and the next time you write, it gets a list of all words that fit into what you're writing, so if the user writes "com", a word that may appear is "complex", that is, if the user has written it anytime in the past.
      A popup will show up whenever the user writes with the list of words, the way to select one of the words from the list is to scroll with the mouse wheel, and middle click. The popup timeout is 2.5 secs.
      Best regards.
       
      PS for the next step would be nice to save words as they are, for example emails, as it is it doesn't get @ for example.
       
       
      Completer 1.0.exe
      AComp.ico
      Completer 1.0.au3
    • TheSaint
      By TheSaint
      Here is the bare bones of a UDF I have started work on.
      Mostly just a proof of concept at this stage, and still need to add some functions and dress the UDF up a bit ... to look like a UDF ... though it has my own distinct styling, especially as I have never really developed a UDF before now .... used plenty and modified plenty though. I've even invented my own UDF variable naming convention, which I am sure some of you will be aghast at. I work with what feels best for me, but others are free to adapt if they wish.
      The idea is to emulate the simplicity of INI files, but gain the benefits of SQL.
      Two scripts are provided.
      (1) The UDF, a work in progress - SimpleSQL_UDF.au3
      (2) An example or testing script - UDF_Test.au3
      Another first for me, is creating a 2D array from scratch, never done that before, that I can recall ... never had a need, and even for 1 dimension arrays, for a long time now, I have just used _StringSplit to create them. So I needed a bit of a refresher course, which my good buddy @TheDcoder assisted me with ... not without some angst I might add. LOL
      SimpleSQL_UDF.zip
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      Hopefully the usage is self-evident ... just change the Job number variable in the UDF_Test.au3 file to check the existing functions out.
      Enjoy!
      P.S. This is also related to a new program I have just finished and uploaded - INItoSQL DB
    • reida
      By reida
      Hello. On page there is mail address. How to keep in a text file this address? 
      It is page and email
      https://alpari.com/
      info@alpari.com
    • caramen
      By caramen
      Hey.  
       
      I requested help about how to get a value from a text in a variable. 
      Now i know how to do that. But i learned with the command FileRead. Now i whould like to know how to replace the command :
      FileRead('Dossier.txt') The purpose is to read a webpage text. To find some value inside. 
       
      Btw i tryed to play with WindowsInfo.au3 but i dont got much thing.  
    • xtcislove
      By xtcislove
      Hello,
      as a start in Autoit i tried something i was missing since im using Autoit. 

      I build a custom MessageBox which has a large amount of custom options and which scales its size on the parameters you set. 

      Aviable Settings:
      -Title
      -Unlimited Buttons
      -Text Color (Buttons, Text)

      -Background Color (Msgbox, Buttons, Label) 

      -Button Timeout
      -Autoclose Timeout
      -Icon (Default, No Icon, Custom)

      -Label/ Button Style. 
      -Transparency

      I tried to keep this as close as i could to a Msgbox i was used too on my batch times.

      After i was ready i realised, @Melba23 probably build a way better msgbox which would have suit my needs enterly, anyway thanks to @Melba23 because i use his Stringsize UDF. 

       
       
      local $Message = _sMsgBox("Test", 6, "Continue?") if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")  
      ScalingMessageBox.au3
×