What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Edit text while typing

Edit text while typing
Author: Message:
#BG
New Member
*

Avatar

Posts: 7
Joined: Jul 2010
O.P. Huh?  Edit text while typing
I'm pretty much a beginner in scripting. I'd like to make to make a script that changes one or more characters to an other one in the chat window while typing. Should I use OnEvent_ChatWndEditKeyDown to monitor every key I press? Can I use ChatWnd.EditText to delete just what I wrote, and put something else in it's place? This is what I've got so far:

code:
function OnEvent_ChatWndEditKeyDown(pChatWnd, nKeyCode, bCtrl, bShift)
{
  // Declare a variable to hold the value of the 2 virtual key
  var VK_2 = 0x32;
       
  // Check if the key pressed are Shift and 2
  if (nKeyCode == VK_2 && bShift == true)
  {
    // Validate that we can type
    if (pChatWnd.EditChangeAllowed == true)
    {
      // Gain access to the contact object
      var oContact = new Enumerator(pChatWnd.Contacts).item();

      // Validate that the contact is not blocked and that they are on the MSN network
      if (oContact.Blocked == false && oContact.Network == NETWORK_MSN)
      {
          ChatWnd.EditText = ""; // Now how should I use it?
      }
    }
  }
}

Thanks for any help!
03-13-2011 06:59 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Edit text while typing
Couldn't you replace the characters in the OnEvent_ChatWndSendMessage function?
03-13-2011 07:14 PM
Profile E-Mail PM Find Quote Report
#BG
New Member
*

Avatar

Posts: 7
Joined: Jul 2010
O.P. RE: Edit text while typing
quote:
Originally posted by matty
Couldn't you replace the characters in the OnEvent_ChatWndSendMessage function?
It would be important to leave the opportunity to the user to check the auto correction, and change it back if needed. Is it more complicated this way?
03-13-2011 07:45 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Edit text while typing
It's as simple as:
Javascript code:
ChatWnd.EditText_ReplaceSel("my replacement");
return true;

When Shift+2 is pressed, the current selection is replaced with whatever you pass to that method. When the user hasn't selected anything but is simply typing, Plus! will treat this as a selection at the current position with zero length. Therefore when you call EditText_ReplaceSel, your replacement will be inserted at the current position. After replacing the selection, simply return true to make Plus! and Messenger stop processing this key. :)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
03-13-2011 10:38 PM
Profile E-Mail PM Web Find Quote Report
#BG
New Member
*

Avatar

Posts: 7
Joined: Jul 2010
O.P. Define ChatWnd
It's really simple then. :) However how should I define the ChatWnd object? (I still get an error and just can't figure out more from the documentations.)
03-14-2011 01:21 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Edit text while typing
quote:
Originally posted by #BG
Javascript code:
function OnEvent_ChatWndEditKeyDown(pChatWnd, nKeyCode, bCtrl, bShift)
{
  // Declare a variable to hold the value of the 2 virtual key
  var VK_2 = 0x32;
       
  // Check if the key pressed are Shift and 2
  if (nKeyCode == VK_2 && bShift == true)
  {
    // Validate that we can type
    if (pChatWnd.EditChangeAllowed == true)
    {
      // Gain access to the contact object
      var oContact = new Enumerator(pChatWnd.Contacts).item();
 
      // Validate that the contact is not blocked and that they are on the MSN network
      if (oContact.Blocked == false && oContact.Network == NETWORK_MSN)
      {
          ChatWnd.EditText = ""; // Now how should I use it?      }
    }
  }
}


You declared the function pChatWnd so as such any references need to be pChatWnd not ChatWnd as I have highlighted in your code.
03-14-2011 02:12 AM
Profile E-Mail PM 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