Predictive text toggle

Post your working scripts, libraries and tools.
LightRecon
Posts: 4
Joined: 23 Mar 2024, 10:31

Predictive text toggle

Post by LightRecon » 23 Mar 2024, 18:26

Have you ever wanted to have predictive text, like on a mobile phone, but for Windows? Where, as you type characters, a window pops up with suggestions (predictions) of the word you're trying to enter based on what you've already typed. This "Hotkey" provides that functionality. It is a toggle that enables/disables this feature for most Windows input fields. Currently I have set it to use the Win+T key combination, but feel free to change it to whatever makes sense to you.

I find it useful for quick text entry and spell checking. When the popup window appears, either click on the word you want, or press the up arrow key and then right or left arrow keys to select the word you want, and then press [Enter]. If the word you want isn't there, type some more characters. Pressing a punctuation key after [Enter] will auto delete the trailing space. It's easier than it sounds. Enjoy!

If you're interested in trying it, copy this "Hotkey" to your AHK file and give it a go.

Code: Select all


;Predictive text toggle
;Requires AutoHotkey v2+
;Version 1 - 2024/03/23
;by LightRecon - [email protected]

#t::
{
PTValue := RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Input\Settings", "EnableHwkbTextPrediction")
If PTValue = 0
{
RegWrite 1, "REG_DWORD", "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Input\Settings", "EnableHwkbTextPrediction"
result := MsgBox("Predictive Text is ON",,"T2")
}
else
{
RegWrite 0, "REG_DWORD", "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Input\Settings", "EnableHwkbTextPrediction"
result := MsgBox("Predictive Text is OFF",,"T2")
}}


This is a AutoHotkey 2+ "Hotkey", but can be modified to work with previous versions. I have tested it on Win10, butshould also work on Win11. And it might work with 7 or 8. YMMV

CAVEAT: One interesting thing about the text prediction feature in Windows is that it learns your typing habits, so it can make better suggestions in the future. Even though this feature can be pretty useful, it can also be problematic. For example, the text prediction engine can even learn your passwords as you type them. Since this feature is mainly intended as an assistive technology, in certain situations it is not safe.

- LightRecon -

LightRecon
Posts: 4
Joined: 23 Mar 2024, 10:31

Predictive text toggle

Post by LightRecon » 24 Mar 2024, 07:27

Version 1.1 - refined

If you have any questions or comments about this Hotkey please ask.

Code: Select all


;Predictive text toggle
;Requires AutoHotkey v2+
;Version 1.1 - 2024-03-24
;by LightRecon - [email protected]

#t::
{RegPTValue := RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Input\Settings", "EnableHwkbTextPrediction")
switch RegPTValue
{
case 0:
RegWrite 1, "REG_DWORD", "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Input\Settings", "EnableHwkbTextPrediction"
MsgBox("   Predictive text is ON   ","Predictive text control . . .","Icon! T2")
return
case 1:
RegWrite 0, "REG_DWORD", "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Input\Settings", "EnableHwkbTextPrediction"
MsgBox("   Predictive text is OFF   ","Predictive text control . . .","Icon! T2")
return
}}


reddyshyam
Posts: 38
Joined: 24 Jul 2023, 04:34

Re: Predictive text toggle

Post by reddyshyam » 25 Mar 2024, 04:48

Hi @LightRecon

This script just enables or disables text prediction but how do we actually see predictions as we type? Also this is only for few languages sadly.

I run the above script it complains file not found for EnableHwkbTextPrediction. I checked the registry and there is no entry for this keyword. I have enabled it via settings for now but I guess you should handle the missing case?

LightRecon
Posts: 4
Joined: 23 Mar 2024, 10:31

Re: Predictive text toggle

Post by LightRecon » 25 Mar 2024, 16:21

My first thought was that some part of the Windows assistive framework isn't installed or initialized properly on your system. The error happens because the EnableHwkbTextPrediction REG_DWORD wasn't found in your Windows registry. What version of Windows are you trying to run this on? First thing to try: Go to Settings -> Devices -> Typing. Then look for "Hardware keyboard". There should be a switch labeled "Show suggestions as I type". Is that entry there? This Microsoft support page describes it.

https://support.microsoft.com/en-us/windows/enable-text-suggestions-in-windows-0bf313ca-c992-4173-aa5f-8341d3953498

If it is there try turning it on and then running this Hotkey again. Or you can try merging the attached Zipped REG file to create, and turn on, this value.

EnableHwkbTextPrediction.zip
Zip file of EnableHwkbTextPrediction.reg
(368 Bytes) Downloaded 7 times

But from what I'm reading sometimes Windows Update screws up this setting. Anyway in the next few days I'm going to update this Hotkey script to take care of this edge case, so be on the lookout for a new version. Till then try the Microsoft settings, or the ZIP file, and see if that helps. Take care.

LightRecon
Posts: 4
Joined: 23 Mar 2024, 10:31

Re: Predictive text toggle

Post by LightRecon » 27 Mar 2024, 07:36

Hi @reddyshyam
reddyshyam wrote: Also this is only for few languages sadly.
It seems Windows Predictive Text currently only supports Latin-script alphabets. And it's my understanding that you can have up to 3 of these languages active at the same time, probably due to a limitation with the Windows language engine, but there are many more than 3 languages based on Latin-script alphabets to select from.

See these URLs for more information:

https://support.microsoft.com/en-us/windows/enable-text-suggestions-in-windows-0bf313ca-c992-4173-aa5f-8341d3953498

https://support.microsoft.com/en-us/windows/check-whether-your-version-of-windows-supports-multiple-languages-eaf060a6-3642-4612-6b75-b34e57a08abf

https://pureinfotech.com/enable-multilingual-text-prediction-windows-10/

https://www.pcmag.com/how-to/how-to-add-support-for-another-language-in-windows-10

https://en.wikipedia.org/wiki/List_of_Latin-script_alphabets

TMI? - HTH

Post Reply

Return to “Scripts and Functions (v2)”