What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [HELP] Get cursor position (X, Y) & set window position (X, Y)

Pages: (2): « First [ 1 ] 2 » Last »
[HELP] Get cursor position (X, Y) & set window position (X, Y)
Author: Message:
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. [HELP] Get cursor position (X, Y) & set window position (X, Y)
Hi,

Another question:

I'd like to know whether there's a way to get the cursor's position (the flickering vertical "line") in a chat window, and setting a window's position to the cursor's (like Plus! does when "/" is the 1st character).

I have once read about the 2nd, but never about the 1st..

Greetz..

This post was edited on 05-15-2008 at 04:24 PM by SmokingCookie.
05-15-2008 04:11 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
Where do you mean? In the chat window, you have the history area (where the sent and received messages are) and the typing area (where you type your messages).

For the first one, there are ChatWnd.HistoryText_GetCurSelStart() and ChatWnd.HistoryText_GetCurSelEnd() functions which let you get the current selection in the history. However, it is not possible to set the selection there.
For the second one, you can use ChatWnd.EditText_GetCurSelStart() and ChatWnd.EditText_GetCurSelEnd() to retrieve the selection and use ChatWnd.EditText_SetCurSel(Start, End) to set it.

Note: if the start and end of a selection are equal, it means that the typing cursor is at that position and has nothing selected. That's what your flickering vertical line is. ;)

Although I don't really understand what you mean with "setting the window's position to the cursor's"... :-/

This post was edited on 05-15-2008 at 04:23 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
05-15-2008 04:21 PM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
What  mean is: Plus! opens a window with the commands at the cursor's position in the typing area, as soon as "/" is typed (as long as its character index ix 0). I'd like to do the same (using OnEvent_ChatWndEditKeyDown). Here for, I need the cursor's X and Y position. Is there a way to get it? I think it'd be something like this:
code:
Interop.Call(DllName,"GetCursorPos",ChatWnd.Handle);
//DllName is probably the name of some system DLL like User32.dll or something


This post was edited on 05-15-2008 at 04:32 PM by SmokingCookie.
05-15-2008 04:29 PM
Profile PM Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
35 / Male / Flag
Joined: Oct 2004
RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
GetCursorPos refers to the position of the mouse pointer, not the writing cursor thingy.
05-15-2008 04:31 PM
Profile PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
Okay... Now I need the writing cursot's position. Is there a way to get it?
05-15-2008 04:33 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
Actually, it's very tough to do this. You'd have to know the font face and font size and the size of the typing area itself to calculate the size of the text and find the position of the typing cursor. Plus! does this pretty good with the Quick Emoticons menu, but there are no script features available to achieve this with a simple Plus! script.

Maybe you should talk to Patchou and ask how you could do it? :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
05-15-2008 04:38 PM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
Okay :P

Would Plus! call a DLL to locate the writing cursor? (Sorry, but contacting Patchou is the last thing I would do.. To prevent me from flooding his mailbox :P )
05-15-2008 04:42 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
quote:
Originally posted by SmokingCookie
Would Plus! call a DLL to locate the writing cursor?
I highly doubt it. I think the way Plus does it, is by calculating the bounding box of the text before the cursor using the font face and size and then use that to find out where to draw the pop-up. Only problem is that a script can't get Messenger's font face and size, or the size of the typing box (for word wrapping).
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
05-15-2008 05:53 PM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
Hmm.. So you think I should figure out how big the rectangle of the typing area is (this data is probably somewhere not in the registry..), do let some maths do their job and set the window's position?

This post was edited on 05-15-2008 at 07:42 PM by SmokingCookie.
05-15-2008 07:25 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [HELP] Get cursor position (X, Y) & set window position (X, Y)
To get the Caret position you can use the GetCaretPos. Now this is in relation to the Caret position in the text box you are typing in now the screen.

The IMConvInputHeight2 key located in the registry (HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger\PerPassportSettings\1959057673) tells you the height of the input box.

code:
var prePOINT = Interop.Allocate(8);
var newPOINT = Interop.Allocate(8);

MsgPlus.AddTimer('x', 100);

function OnEvent_Timer(sTimerId) {
    Interop.Call('user32', 'GetCaretPos', newPOINT);
    if ( newPOINT.ReadDWORD(0) !== prePOINT.ReadDWORD(0) || newPOINT.ReadDWORD(4) !== prePOINT.ReadDWORD(4) ) {
        Interop.Call('kernel32', 'RtlMoveMemory', prePOINT, newPOINT, 8);
        Debug.Trace('x : '+newPOINT.ReadDWORD(0)+'\ty: '+newPOINT.ReadDWORD(4));
    }
    MsgPlus.AddTimer('x', 100);
}

This post was edited on 05-15-2008 at 08:01 PM by matty.
05-15-2008 07:59 PM
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« 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