Jump to content

Autocorrect Script


Guest rathore
 Share

Recommended Posts

Guest rathore

while typing i use shortcuts (like plz for please) to save time, but i don't think that it looks so nice so i'm thinking of using AU3 to write an AutoCorrect script that'd change such things... the trouble is, i just don't know how to start!

plz help!

Edited by rathore
Link to comment
Share on other sites

Guest rathore

it should do either of these, preferable the first:

1. change text while i'm typing

2. after i've written my stuff, i press a hotkey and it makes all changes.

but in any of the cases it should work without disturbing anything else, like the text might not just b in notepad like windows, it may be in OE's new message with some pictures etc.

and making additions to the script should be easy (for adding more replacements)... i don't mind adding a stringreplace for every addition, but a diff loop for every addition is not preferable.

Link to comment
Share on other sites

Guest rathore

something that i tried... doesn't work & keeps sending cursor to beginning of text!!

:whistle:

While 1
   Sleep(1000)
   scan()   
Wend

Func scan()
   $CONT=ControlGetFocus("")
   $TEXT=ControlGetText("", "", $CONT)
   $TEXT2=StringReplace($TEXT, "shud", "should")
   If $TEXT <> $TEXT2 Then ControlSetText("", "", $CONT, $TEXT)
EndFunc  ;==>scan
Link to comment
Share on other sites

Guest rathore

the script i posted above had 1 or 2 errors, i've rectified them below.

While 1
   Sleep(1000)
   scan()   
Wend

Func scan()
   $CONT=ControlGetFocus("")
   $TEXT=ControlGetText("", "", $CONT)
   
  ;make additions here
   $TEXT2=StringReplace($TEXT, "shud", "should")
   $TEXT2=StringReplace($TEXT2, "plz", "please")
   
   If $TEXT <> $TEXT2 Then ControlSetText("", "", $CONT, $TEXT2)
   If $TEXT <> $TEXT2 Then ControlSend("", "", $CONT, "{end}")
EndFunc

the problems with this:

{end} isn't right, i want the cursor to be at the place where it was.

doesn't work with all windows.

i'll check your script now larry.

Link to comment
Share on other sites

Wouldn't a text file using a format similar to this be the best way to add new words (It doesn't force a script recompile every time and would work with phrases...)

"word or phrase to replace" "Word or phrase that will be used"
"ie1" "example1"
"Short phrase" "Much longer phrase will be inserted"
Link to comment
Share on other sites

Guest rathore

Valik, that'd b the best way!

i had this or a text file in .ini format (with changethis=changeto) format on my mind, but i didn't dare ask thinking that'd b too wishful.

and Larry (u certainly rock!), here r the comments:

.the method is great!

.disable casesense (or make it an option)

.the esc key method should be changed to (i guess) a 2-3 second delay.

.the script didn't work in new message window, and even this window i'm writing the reply in.

Edited by rathore
Link to comment
Share on other sites

Guest rathore

hi !

i've done 2 modifications to Larry's script. firstly it's not checking case sense (i'd a hunch that == checks case sense as there was no specific declaration in script, plz tell me where is this in help file). and secondly, after a 3 second delay the script doesn't autocomplete.

but Larry, PLEASE tell me how to get this to work in all windows?!!... it doesn't even work in MSWord or wordpad windows!!

some ideas! any ideas!!!....PLEASE ... :whistle:

Dim $g_BOOL = 0
Dim $g_hWnd = 0
Dim $g_szOBJ = ""

HotKeySet("{ENTER}","Init")
HotKeySet("{ESC}","Quit")

Intro()

Opt("WinTitleMatchMode",4)
AdlibEnable("Harvest")

While WinExists($g_hWnd)
Sleep(200)
Wend


Func Harvest()
If Not WinActive($g_hWnd) Then Return
$g_szOBJ = ControlGetFocus($g_hWnd)
$nLine = ControlCommand($g_hWnd,"",$g_szOBJ,"GetCurrentLine","")
$szText = ControlCommand($g_hWnd,"",$g_szOBJ,"GetLine",$nLine)
CheckAClist($szText)
EndFunc


Func CheckAClist(ByRef $szText)
If StringRight($szText,5) = "Larry" Then
 $g_BOOL = 0
 AutoComplete("Larry")
EndIf
EndFunc


Func Complete()
ControlSend($g_hWnd,"",$g_szOBJ,$g_szComplete,1)
HotKeySet("{ENTER}")
ToolTip("")
EndFunc

Func AutoComplete($token)
Global $g_szComplete = " rocks!"
$xy = WinGetCaretPos()
If $xy[1] < 30 Then
 $xy[1] = $xy[1] + 20
Else
 $xy[1] = $xy[1] - 20
EndIf
HotKeySet("{ENTER}","Complete")
ToolTip($token & $g_szComplete,$xy[0],$xy[1])
sleep (3000)
HotKeySet("{ENTER}")
ToolTip("")

EndFunc


Func Init()
HotKeySet("{ENTER}")
$g_hWnd = "handle=" & WinGetHandle("")
$g_BOOL = 1
SplashOff()
EndFunc


Func Quit()
Exit
EndFunc


Func Intro()
SplashTextOn("AutoComplete",@LF & "Click the window to use AutoComplete with" & @LF & _
 "and Press [ENTER]. Press [ESC] to Exit.",400,100,-1,-1,16)
While Not $g_BOOL
 Sleep(100)
Wend
EndFunc
Link to comment
Share on other sites

Guest rathore

It will never work in ALL windows simply because the control functions don't work in all windows.

really?... that's too sad! :whistle:

so how should i go about it? ... write something from scratch that doesn't use control functions?... or drop the whole idea?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...