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

    • nooneclose
      By nooneclose
      I am sure you guys know of a simple solution but I am still kind of new to AutoIt and its special functions. I want my code to be able to know how to encrypt and decrypt "A" and "a" as two different chars.
      my code is very long so here is just a snippet/example of it.  
      ;Encode== Global $charAA = "" ; ( Capital letter A ) = Global 184 = ¸ ( Cedilla ) $charAA = $charAA & Chr(65) Global $chara = "" ; ( Lowercase letter a ) = Global 251 = û ( û Latin Small Letter U With Circumflex ) $chara = $chara & Chr(97) ;Decode== Global $ch184 = "" ;( Copyright symbol ) = $charAA $ch184 = $ch184 & Chr(184) Global $ch251 = "" ;( û Latin Small Letter U With Circumflex ) = $chara $ch251 = $ch251 & Chr(251) ;Encode== stringreplace($test_String, $charAA, $ch184) stringreplace($test_String, $chara, $ch251) ;Decode== stringreplace($$new_String, $ch184, $charAA) stringreplace($$new_String, $ch251, $chara) ( NOTE: my stringreplace function is nested in my actual code. I only separated them here for readability. )

      I know there are better ways to Encrypt and Decrypt a message but I'm doing this as a fun side project for me and a select group of friends to enjoy. 
      Again My code is not encrypting or decrypting capitals and lower case properly even though I use their ANSI codes. 
       
      Example: Input "A a B b"  Encrypt: ". . $ $"  Decrypt: "A A B B"
      Any and all help will be greatly appreciated.  
    • caramen
      By caramen
      I watched _OL_ItemSend&_OL_ItemFind&_OL_ItemCreate in OutlookEx UDF but hmmm
       
      Since it use the test environnement i cant get the orders of the mail creation
       
      Can someone make me win some time of reading all exemples script and lead me how to do one ?
      That whould be lovely.
      Gnight
    • Tersion
      By Tersion
      Here the this wiki page with list of available UDFs for data compression. For my tasks I only need ZIP support, so I started looking at pure AutoIt UDFs without any 3rd party dlls. And found out that most of available realizations uses standard ("native method") Windows dll - "zipfldr.dll". So for now I chose ZIP UDF by wraithdu. I've tested it on Windows 7 (x64) and it seem works fine. But here the comment from another topic where user says that Windows 10 discontinued support of "zipfldr.dll". Now I confused. I don't have around any Windows 10 machine to tested it. So maybe someone could confirm or deny that? Or maybe would better to switch to UDF with 7zip dll?
      I need an advice...
    • 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  (12 downloads previously)
      (I have now completed all the functions I intended to. My next update will be a big improvement, bringing things more inline with my latest INItoSQL DB program changes.)
      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
    • 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
×