Jussip Posted September 13, 2008 Posted September 13, 2008 (edited) Hey, i need script for chaning specified words or phrases into something else, Ex. You write: Hey, how are you doing? When program is on, it changes the text to: Ahoy! How are ye doin'? Really, im making little mod to a game, and i need help with this. Suggestions? Edited September 13, 2008 by jiibah
Andreik Posted September 13, 2008 Posted September 13, 2008 Hey, i need script for chaning specified words or phrases into something else,Ex.You write:Hey, how are you doing?When program is on, it changes the text to:Ahoy! How are ye doin'?Really, im making little mod to a game, and i need help with this.Suggestions?Read in help file about StringReplace().
Jussip Posted September 13, 2008 Author Posted September 13, 2008 Read in help file about StringReplace().Thanks, i found it, but im bit confused how to use it.Can ye give me an example?
Andreik Posted September 13, 2008 Posted September 13, 2008 Thanks, i found it, but im bit confused how to use it. Can ye give me an example? $GUI = GUICreate("StringReplace",200,200) $M1 = GUICtrlCreateEdit("Hey, how are you doing?",5,5,190,80) $M2 = GUICtrlCreateEdit("",5,90,190,60) $BUTTON = GUICtrlCreateButton("REPLACE",50,170,100,20) GUISetState(@SW_SHOW,$GUI) While 1 $MSG = GUIGetMsg() If $MSG = $BUTTON Then $REPLACE1 = StringReplace(GUICtrlRead($M1),"Hey,","Ahoy!") $REPLACE2 = StringReplace($REPLACE1,"you","ye") $REPLACE3 = StringReplace($REPLACE2,"doing","doin'") GUICtrlSetData($M2,$REPLACE3) ElseIf $MSG = -3 Then Exit EndIf Sleep(15) WEnd
Jussip Posted September 13, 2008 Author Posted September 13, 2008 $GUI = GUICreate("StringReplace",200,200) $M1 = GUICtrlCreateEdit("Hey, how are you doing?",5,5,190,80) $M2 = GUICtrlCreateEdit("",5,90,190,60) $BUTTON = GUICtrlCreateButton("REPLACE",50,170,100,20) GUISetState(@SW_SHOW,$GUI) While 1 $MSG = GUIGetMsg() If $MSG = $BUTTON Then $REPLACE1 = StringReplace(GUICtrlRead($M1),"Hey,","Ahoy!") $REPLACE2 = StringReplace($REPLACE1,"you","ye") $REPLACE3 = StringReplace($REPLACE2,"doing","doin'") GUICtrlSetData($M2,$REPLACE3) ElseIf $MSG = -3 Then Exit EndIf Sleep(15) WEnd Wow, great one. Now, how about, if you just start writing "Hi", it automaticly changes to "Ahoy", Its possible?
Andreik Posted September 13, 2008 Posted September 13, 2008 Wow, great one.Now, how about, if you just start writing "Hi", it automaticly changes to "Ahoy", Its possible?Play with this example with different words. In exaple if is found "Hey," will be replace with "Ahoy!", if is found "you" will be replace with "ye", etc. You can replace for example only three times a word with another (the fourth parameter of the function).
Jussip Posted September 13, 2008 Author Posted September 13, 2008 Play with this example with different words. In exaple if is found "Hey," will be replace with "Ahoy!", if is found "you" will be replace with "ye", etc. You can replace for example only three times a word with another (the fourth parameter of the function).I have played with 'em alot, and i think my head is exploding. wont get it done.Could ye just give me script so i can change the strings and add some =)Please.
Andreik Posted September 13, 2008 Posted September 13, 2008 I have played with 'em alot, and i think my head is exploding. wont get it done. Could ye just give me script so i can change the strings and add some =) Please. $GUI = GUICreate("StringReplace",200,230) $M1 = GUICtrlCreateEdit("Hey, how are you doing?",5,5,190,80) $W1 = GUICtrlCreateInput("Hey,",5,90,90,20) $W2 = GUICtrlCreateInput("Ahoy!",105,90,90,20) $M2 = GUICtrlCreateEdit("",5,120,190,60) $BUTTON = GUICtrlCreateButton("REPLACE",50,190,100,20) GUISetState(@SW_SHOW,$GUI) While 1 $MSG = GUIGetMsg() If $MSG = $BUTTON Then $REPLACE = StringReplace(GUICtrlRead($M1),GUICtrlRead($W1),GUICtrlRead($W2)) GUICtrlSetData($M2,$REPLACE) ElseIf $MSG = -3 Then Exit EndIf Sleep(15) WEnd
martin Posted September 13, 2008 Posted September 13, 2008 If you want the text to change automatically as you type then you can have something like this. expandcollapse popup#include <windowsconstants.au3> #include <GUIConstants.au3> #include <editconstants.au3> $GUI = GUICreate("StringReplace", 200, 230) $M1 = GUICtrlCreateEdit("Hey, how are you doing?", 5, 5, 190, 80) $W1 = GUICtrlCreateInput("Hey,", 5, 90, 90, 20) $W2 = GUICtrlCreateInput("Ahoy!", 105, 90, 90, 20) $M2 = GUICtrlCreateEdit("", 5, 120, 190, 60) $BUTTON = GUICtrlCreateButton("REPLACE", 50, 190, 100, 20) GUISetState(@SW_SHOW, $GUI) GUIRegisterMsg($WM_COMMAND, "A_WM_COMMAND") $ChangeMade = False While 1 $MSG = GUIGetMsg() If $MSG = $BUTTON Then $REPLACE = StringReplace(GUICtrlRead($M1), GUICtrlRead($W1), GUICtrlRead($W2)) GUICtrlSetData($M2, $REPLACE) ElseIf $MSG = -3 Then Exit EndIf Sleep(15) If $ChangeMade Then ConsoleWrite($ChangeMade & @CRLF) $ChangeMade = False $text = GUICtrlRead($M1) $replacements = 0 $text = StringReplace($text, "Hey,", "Hi,") $replacements += @extended $text = StringReplace($text, "you ", "yi ") $replacements += @extended If $replacements > 0 Then GUICtrlSetData($M1, $text) EndIf WEnd Func A_WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam) Local $setHK = False $nNotifyCode = BitShift($iwParam, 16) $nID = BitAND($iwParam, 0x0000FFFF) $hCtrl = $ilParam If $nNotifyCode = $EN_CHANGE Then If GUICtrlGetHandle($M1) = $ilParam Then $ChangeMade = True; EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>DB_WM_COMMAND Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
oMBRa Posted September 13, 2008 Posted September 13, 2008 I think he didnt mean that... I believe he meant to change the text u wrote... for example u are chatting on msn, u write Hi and the program should replace it with something else ( not change after u sent the message )
Jussip Posted September 13, 2008 Author Posted September 13, 2008 I think he didnt mean that... I believe he meant to change the text u wrote... for example u are chatting on msn, u write Hi and the program should replace it with something else ( not change after u sent the message )Exacly! That's what i ment
Andreik Posted September 13, 2008 Posted September 13, 2008 Exacly! That's what i ment This soundS like a hot string.
Jussip Posted September 13, 2008 Author Posted September 13, 2008 This soundS like a hot string.How cool. Any way to create it?
Andreik Posted September 13, 2008 Posted September 13, 2008 How cool. Any way to create it?Authors: Manadar, LarryDalooza, piccaso
martin Posted September 13, 2008 Posted September 13, 2008 I think he didnt mean that... I believe he meant to change the text u wrote... for example u are chatting on msn, u write Hi and the program should replace it with something else ( not change after u sent the message )Maybe I have misunderstood something but my script does change it as you type. If you type Hey, it gets changed to Hi, It doesn't change what is placed there to start with untill some text is typed because the way I did it means that the replacements are only made when something changes. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now