What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Cursor Position in Plus text boxes

Cursor Position in Plus text boxes
Author: Message:
win_crook
Junior Member
**


Posts: 63
Reputation: 2
31 / Male / Flag
Joined: Apr 2007
O.P. Cursor Position in Plus text boxes
Is there any way I can get the position of the text cursor in a text box in a plus interface?

I need to insert some text at the current cursor position instead of at the end of the box which is the way I'm currently doing it.

Thanks,
David
04-07-2007 05:47 PM
Profile PM Find Quote Report
Patchou
Messenger Plus! Creator
*****

Avatar

Posts: 8607
Reputation: 201
43 / Male / Flag
Joined: Apr 2002
RE: Cursor Position in Plus text boxes
you can send the EM_GETSEL message. In version 4.21, some new functions have been added to add more support for edit controls.
[Image: signature2.gif]
04-07-2007 06:04 PM
Profile PM Web Find Quote Report
win_crook
Junior Member
**


Posts: 63
Reputation: 2
31 / Male / Flag
Joined: Apr 2007
O.P. RE: Cursor Position in Plus text boxes
Would it be possible for you to give me some guidance on how to do this please? Maybe just a little example to get me started.
04-07-2007 06:21 PM
Profile PM Find Quote Report
felipEx
Scripting Contest Winner
***


Posts: 378
Reputation: 24
35 / Male / Flag
Joined: Jun 2006
RE: RE: Cursor Position in Plus text boxes
quote:
Originally posted by Patchou
you can send the EM_GETSEL message. In version 4.21, some new functions have been added to add more support for edit controls.

Hi Patch.
you would have to consider the use of <MaxLength>   :P

it can be possible with API.
code:
var EM_LIMITTEXT = 0xC5;
Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle("mytxt"), EM_LIMITTEXT, 11 /* or new maxlength value */ , 0);
04-07-2007 08:48 PM
Profile E-Mail PM Find Quote Report
win_crook
Junior Member
**


Posts: 63
Reputation: 2
31 / Male / Flag
Joined: Apr 2007
O.P. RE: Cursor Position in Plus text boxes
Well I've figured out the EM_GETSEL message and it's working fine now. I'm onto the string processing part now, and I'm getting this error:

quote:
Error: Object doesn't support this property or method.
       Line: 40. Code: -2146827850.


This is the code, the middle line is line 40:
code:
var text = Wnd.GetControlText("NameEdit");
var firstHalf = text.substring(0, Start);
var secondHalf = text.substring(Start, before.length);


I'm assuming it's talking about the substring method, but I don't see why it's saying it's unsupported... any ideas?

Thanks,
David
04-08-2007 12:00 PM
Profile PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
RE: Cursor Position in Plus text boxes
what is $Start defined as?
04-08-2007 12:32 PM
Profile E-Mail PM Find Quote Report
win_crook
Junior Member
**


Posts: 63
Reputation: 2
31 / Male / Flag
Joined: Apr 2007
O.P. RE: Cursor Position in Plus text boxes
Here is the code that defines start:
code:
var EM_GETSEL = 0xB0;
var EM_SETSEL = 0xB1;
var Start = Interop.Allocate(32);
Interop.Call("user32", "SendMessageW", Wnd.GetControlHandle("NameEdit"), EM_GETSEL, Start, 0);

04-08-2007 12:36 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Cursor Position in Plus text boxes
quote:
Originally posted by win_crook
Here is the code that defines start:
code:
var EM_GETSEL = 0xB0;
var EM_SETSEL = 0xB1;
var Start = Interop.Allocate(32);
Interop.Call("user32", "SendMessageW", Wnd.GetControlHandle("NameEdit"), EM_GETSEL, Start, 0);


When you are allocating memory to a variable you cannot simply reference the variable itself. In this case the value you are trying to read is a DWORD.

You need to replace:
code:
var text = Wnd.GetControlText("NameEdit");
var firstHalf = text.substring(0, Start);
var secondHalf = text.substring(Start, before.length);


With this
code:
var text = Wnd.GetControlText("NameEdit");
var firstHalf = text.substring(0, Start.ReadDWORD(0));
var secondHalf = text.substring(Start.ReadDWORD(0), before.length);


And where does before come into play?

Also why are you allocating 32 bytes of memory to Start? It should be 4.

This post was edited on 04-08-2007 at 02:44 PM by matty.
04-08-2007 02:44 PM
Profile E-Mail PM Find Quote Report
win_crook
Junior Member
**


Posts: 63
Reputation: 2
31 / Male / Flag
Joined: Apr 2007
O.P. RE: Cursor Position in Plus text boxes
Thanks a lot for that :D... the before doesn't come into play, I forgot to change it to text for this example. It's all working fine now.
04-08-2007 02:49 PM
Profile PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
29 / Male / Flag
Joined: Apr 2006
Status: Away
RE: Cursor Position in Plus text boxes
quote:
Originally posted by effection
$Start
He never used the variable $Start. It was Start. Please don't confuse with it. This is not php that you'll need $ for a variable. This is JScript.

This post was edited on 04-08-2007 at 03:41 PM by Felu.
04-08-2007 03:41 PM
Profile E-Mail 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