Jump to content

Replace Input String with Predefined String?


Recommended Posts

Hello,

Is is possible to make an auto word correcting function?

Where as I type "ello" it will then automatically (or upon pressing space) convert "ello" to "hello".

I know this is possible with AutoHoykey so I figure there must be something similar in AutoIt.

I was messing around with this.

HotKeySet("1" + "2", "Test1") 
Func Test1() 
TrayTip("Congrats", 1, 1) 
EndFunc 
While(1)
WEnd

Just to get the input string (Hotkey) to work, but obviously that's not going to work. So if anyone could provide assistance I will be very grateful.

PS: Depending on the speed at which this gets a response, I may not reply because I'm taking off for the next couple days. However I'll make sure to reply with my thanks when I'm back. >_<

EDIT: Also note, I'm not trying to get it to replace all of the "ello" strings, only the ones I type while it's running.

Edited by JohnCleese

"I find it rather easy to portray a businessman. Being bland, rather cruel and incompetent comes naturally to me."

Link to comment
Share on other sites

Hello,

Is is possible to make an auto word correcting function?

Where as I type "ello" it will then automatically (or upon pressing space) convert "ello" to "hello".

I know this is possible with AutoHoykey so I figure there must be something similar in AutoIt.

I was messing around with this.

HotKeySet("1" + "2", "Test1") 
Func Test1() 
TrayTip("Congrats", 1, 1) 
EndFunc 
While(1)
WEnd

Just to get the input string (Hotkey) to work, but obviously that's not going to work. So if anyone could provide assistance I will be very grateful.

PS: Depending on the speed at which this gets a response, I may not reply because I'm taking off for the next couple days. However I'll make sure to reply with my thanks when I'm back. >_<

EDIT: Also note, I'm not trying to get it to replace all of the "ello" strings, only the ones I type while it's running.

What is meant by "1" + "2": only "1", only "2", or both?
Link to comment
Share on other sites

What is meant by "1" + "2": only "1", only "2", or both?

I was trying to get it to take it in order. So if I type 1 then 2 side by side it would perform the function.

But I discovered it's actually just doing the math so when I press three it performs the function. >_<

I doubt in the end it will be using a Hotkey at all.

"I find it rather easy to portray a businessman. Being bland, rather cruel and incompetent comes naturally to me."

Link to comment
Share on other sites

Do you want an Dictonary? or just a few words

for a few words, use an 2D array

Dim $aReplacments[3][2] = [["ello", "Hello"],["odbye", "Goodbye"],["Tjeeenare", "Tjenare"]]
#include <Array.au3>
ConsoleWrite( _ReplaceWord($aReplacments, "ello") & @CRLF)

Func _ReplaceWord($aReplacments, $Word)
    $Index = _ArraySearch($aReplacments, $Word)
    If $Index <> -1 Then
        Return $aReplacments[$Index][1]
    Else
        Return -1
    EndIf
EndFunc   ;==>_ReplaceWord
[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

Dim $aReplacments[3][2] = [["ello", "Hello"],["odbye", "Goodbye"],["Tjeeenare", "Tjenare"]]
#include <Array.au3>
ConsoleWrite( _ReplaceWord($aReplacments, "ello") & @CRLF)

Func _ReplaceWord($aReplacments, $Word)
    $Index = _ArraySearch($aReplacments, $Word)
    If $Index <> -1 Then
        Return $aReplacments[$Index][1]
    Else
        Return -1
    EndIf
EndFunc   ;==>_ReplaceWord

Thanks for the suggestion, I'll look into arrays more for future refrence. :(

Though I couldn't manage to get the above script working. (It ran fine, but didn't seem to do anything)

Anyways, I found an easier way to do it using autohotkey and autoit scripts together. >_<

Also for anyone interested the AutoHotkey function was.

PutUni(DataIn)
{
   SavedClip := ClipBoardAll
   ClipBoard =
   If RegExMatch(DataIn, "^[0-9a-fA-F]+$")
   {
      Loop % StrLen(DataIn) / 2
         UTF8Code .= Chr("0x" . SubStr(DataIn, A_Index * 2 - 1, 2))
   }
   Else
      UTF8Code := DataIn
   Transform, ClipBoard, Unicode, %UTF8Code%
   Send ^v
   Sleep 100 ;Generous, less wait or none will often work.
   ClipBoard := SavedClip
   return
}

"I find it rather easy to portray a businessman. Being bland, rather cruel and incompetent comes naturally to me."

Link to comment
Share on other sites

It didn't even write "Hello" in the console?

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

Ahh, no i meant the SciTE console, just below your code (if you use SciTE), Thats where ConsoleWrite() puts it's text.

But you could use a InputBox and MsgBox as well

#include <Array.au3>
Dim $aReplacments[3][2] = [["ello", "Hello"],["odbye", "Goodbye"],["Tjeeenare", "Tjenare"]]
MsgBox(0, "Replacement...", _ReplaceWord($aReplacments, InputBox("", "Enter Word")))

Func _ReplaceWord($aReplacments, $Word)
    $Index = _ArraySearch($aReplacments, $Word)
    If $Index <> -1 Then
        Return $aReplacments[$Index][1]
    Else
        Return -1
    EndIf
EndFunc   ;==>_ReplaceWord
[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

Ahh, no i meant the SciTE console, just below your code (if you use SciTE), Thats where ConsoleWrite() puts it's text.

But you could use a InputBox and MsgBox as well

Oh, I see. Yea the above script works in replacing the words. I could probably get that to work by saving the clipboard, then copy & pasting the array.

However, just for the hell of it. Could you upload a pic of the scite console.

I don't see it at all, I use SciTE4AutoIt3 as my .au3 editor.

"I find it rather easy to portray a businessman. Being bland, rather cruel and incompetent comes naturally to me."

Link to comment
Share on other sites

Oh, I see. Yea the above script works in replacing the words. I could probably get that to work by saving the clipboard, then copy & pasting the array.

However, just for the hell of it. Could you upload a pic of the scite console.

I don't see it at all, I use SciTE4AutoIt3 as my .au3 editor.

Heres a picture of the console:

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

John, make sure you have the full version of SciTE. It must be downloaded separate from the Autoit install. The Autoit install has a minimum version included

8)

Ah ok, thanks for the info, will do. >_<

Heres a picture of the console:

Oohhh lol, the output console. I thought that might have been it. Anyways thanks for that. :(

Although, so using your original script. Where would I have to type ello, for it to be replaced with hello? Would I type it into the output panel?

"I find it rather easy to portray a businessman. Being bland, rather cruel and incompetent comes naturally to me."

Link to comment
Share on other sites

It was not meant to be inputed by user, as an example only it was right here

ConsoleWrite( _ReplaceWord($aReplacments, "ello") & @CRLF)

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
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...