What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Replace EditText

Replace EditText
Author: Message:
ChristianAMD3000
New Member
*


Posts: 4
Joined: Aug 2006
O.P. Replace EditText
Hi @ all friends

i got a big problem

i want replace the words in EditText-box during i write something.
e.g if i write "hallo"--> it must be changed in "Hello".

i used OnEvent_ChatWndSendMessage(); command and its working
but that is not realy usefull becouse i cant change the words if i make a mistake..

i think u all get it what my problem is.
it would be verry greatfull if somebody can help me :|

(Sorry My english *-))
Christian
08-27-2006 10:38 PM
Profile E-Mail PM Find Quote Report
mickael9
Full Member
***


Posts: 117
Reputation: 3
32 / Male / Flag
Joined: Jul 2005
RE: Replace EditText
quote:
Originally posted by ChristianAMD3000
Hi @ all friends

i got a big problem

i want replace the words in EditText-box during i write something.
e.g if i write "hallo"--> it must be changed in "Hello".

i used OnEvent_ChatWndSendMessage(); command and its working
but that is not realy usefull becouse i cant change the words if i make a mistake..

i think u all get it what my problem is.
it would be verry greatfull if somebody can help me :|

(Sorry My english *-))
Christian

Hi,
code:
var Params = {};
var ParamCount = 0;

var Replacements = {
"hallo" : "hello"
};

function OnEvent_ChatWndEditKeyDown(oChatWnd, nKeyCode, bCtrl, bShift)
{
    var sTimerId = "InlineRepl_" + (++ParamCount);
    Params[sTimerId] = oChatWnd;
    MsgPlus.AddTimer(sTimerId,100);
}

function OnEvent_Timer(sTimerId)
{
    if (sTimerId.substr(0, 11) == "InlineRepl_")
    {
        var Wnd        = Params[sTimerId];
        var nSelStart  = Wnd.EditText_GetCurSelStart();
        var nSelEnd    = Wnd.EditText_GetCurSelEnd();
        var nOldLength = Wnd.EditText.length;
        var sText      = Wnd.EditText;
       
        for (sKey in Replacements)
        {
            sText = sText.replace(sKey,Replacements[sKey]);
        }
        if (sText.length < nOldLength)
        {
            nSelStart -= (nOldLength - sText.length);
            nSelEnd   -= (nOldLength - sText.length);
        }
        else if (sText.length > nOldLength)
        {
            nSelStart += (sText.length - nOldLength);
            nSelEnd   += (sText.length - nOldLength);
        }
        Wnd.EditText = sText;
        Wnd.EditText_SetCurSel(nSelStart, nSelEnd);
       
        ParamCount--;
        delete(Params[sTimerId]);
    }
}
08-28-2006 03:31 AM
Profile PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Replace EditText
Have you tested what happens if ParamCount wraps round?
[Image: spartaafk.png]
08-28-2006 03:11 PM
Profile PM Web Find Quote Report
ChristianAMD3000
New Member
*


Posts: 4
Joined: Aug 2006
O.P. RE: Replace EditText
uh!! its working fine.. but too much big ;)
and i cant replace Characters
eg. if  m -> Ma
         ma -> something else..


but i solve it with a simple logik


var meinText ='';
var VK_0 ='';
OnEvent_ChatWndEditKeyDown(ChatWnd,KeyCode)
{

  VK_0 = 32;
  meinText = ChatWnd.EditText;

  If (KeyCode == VK_0) // if i press space the word will be replaced ;)
   {
    meinText = meinText.Replace...............ect;
    ChatWnd.EditText = Text;
    }
}

it was 3'O Clock when i finished ;)

thx a lot 4 all

gruß
Christian

PS: once more ques.. I'm Delphi user can i use Delphi Codes here???8-)
08-28-2006 05:10 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Replace EditText
You can use bbCode to format a post. Use [code]<code>[/code] for code snippets.
[Image: spartaafk.png]
08-28-2006 09:47 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On