Hello,
I need some help with the SendMessage method. I've imported it into C# with
the following statement:
[DllImport("user32.dll", SetLastError=true)]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, long wparam,
int lparam);
and the following for sending the message:
User32.SendMessage(WindowObject_Basic_GDI_Handle, User32.WM_MOUSEMOVE,
User32.MK_LBUTTON, MakeLParam(X, Y));
and below for constructing the lparam:
private int MakeLParam(int LoWord, int HiWord)
{
//System.Diagnostics.Debug.WriteLine("LoWord: " + LoWord2(((HiWord << 16) |
(LoWord & 0xffff))));
return (int) ((HiWord << 16) | (LoWord & 0xffff));
}
Unfortunately, whenever I send a WM_MOUSEMOVE message to a window
(Notepad.exe), the lparam parameter doesn't mike it there!
Spy++ reports X and Y coordinates of 0. (Everything else makes it there ok).
Does anyone have ideas what kind or marshaling I need to do, or if I am
sending the correct data?
Thanks,
Ryan 2 8495
wparam should be int not long.
I prefer to use IntPtr though which would allow you to send a long value.
[DllImport("user32.dll", SetLastError=true)]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wparam,
IntPtr lparam);
SendMessage(this.Handle, 0x200, (IntPtr)(long)0x1, (IntPtr)MakeLParam(X,Y));
--
Mick Doherty http://dotnetrix.co.uk/nothing.html
"Ryan Ross" <ry***@nni.com> wrote in message
news:0s********************@nni.com... Hello,
I need some help with the SendMessage method. I've imported it into C# with the following statement:
[DllImport("user32.dll", SetLastError=true)]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, long wparam, int lparam);
and the following for sending the message:
User32.SendMessage(WindowObject_Basic_GDI_Handle, User32.WM_MOUSEMOVE, User32.MK_LBUTTON, MakeLParam(X, Y));
and below for constructing the lparam:
private int MakeLParam(int LoWord, int HiWord)
{
//System.Diagnostics.Debug.WriteLine("LoWord: " + LoWord2(((HiWord << 16) | (LoWord & 0xffff))));
return (int) ((HiWord << 16) | (LoWord & 0xffff));
}
Unfortunately, whenever I send a WM_MOUSEMOVE message to a window (Notepad.exe), the lparam parameter doesn't mike it there!
Spy++ reports X and Y coordinates of 0. (Everything else makes it there ok).
Does anyone have ideas what kind or marshaling I need to do, or if I am sending the correct data?
Thanks,
Ryan
Ah, that works.
Thank You,
Ryan
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:Oy*************@TK2MSFTNGP15.phx.gbl... wparam should be int not long.
I prefer to use IntPtr though which would allow you to send a long value.
[DllImport("user32.dll", SetLastError=true)] public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wparam, IntPtr lparam);
SendMessage(this.Handle, 0x200, (IntPtr)(long)0x1, (IntPtr)MakeLParam(X,Y));
-- Mick Doherty http://dotnetrix.co.uk/nothing.html
"Ryan Ross" <ry***@nni.com> wrote in message news:0s********************@nni.com... Hello,
I need some help with the SendMessage method. I've imported it into C# with the following statement:
[DllImport("user32.dll", SetLastError=true)]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, long wparam, int lparam);
and the following for sending the message:
User32.SendMessage(WindowObject_Basic_GDI_Handle, User32.WM_MOUSEMOVE, User32.MK_LBUTTON, MakeLParam(X, Y));
and below for constructing the lparam:
private int MakeLParam(int LoWord, int HiWord)
{
//System.Diagnostics.Debug.WriteLine("LoWord: " + LoWord2(((HiWord << 16) | (LoWord & 0xffff))));
return (int) ((HiWord << 16) | (LoWord & 0xffff));
}
Unfortunately, whenever I send a WM_MOUSEMOVE message to a window (Notepad.exe), the lparam parameter doesn't mike it there!
Spy++ reports X and Y coordinates of 0. (Everything else makes it there ok).
Does anyone have ideas what kind or marshaling I need to do, or if I am sending the correct data?
Thanks,
Ryan
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sn |
last post by:
Does anyone know how to use the SendMessage() function to save a text
file in UTF-8 format. what are the Msg, Wparam and the lParam
parameters passed to the function?
|
by: Rudy Velthuis |
last post by:
Hello,
Does anyone know how to create a struct that will marshal to the
following C++ struct A, containing an array of the user defined String10
type:
struct String10
{
char SLen;
char S;
|
by: Jeff |
last post by:
Hi guys
Mattias, thanx for answering my last question
Well, I'm struggling with marshaling a struct that has **ptr to an array of arrays of struct. Why? I'm stuck with it
1. I need to know...
|
by: Mo |
last post by:
I am having problem with marshaling struct in C#.
//the original C++ struct
typedef struct _tagHHP_DECODE_MSG
{
DWORD dwStructSize; // Size of decode
structure.
TCHAR ...
|
by: Nickneem |
last post by:
I' m trying to disable all right mouse clicks by using the
vbAccelerator Windows Hooks Library
The small (systray / console) app. must catch all (right) mouseclicks
before they are received by...
|
by: alexwhitman |
last post by:
Hi,
I'm trying to port a c++ class to c# and in the c++ class I have a
struct defined as:
struct SNARLSTRUCT {
SNARL_COMMANDS cmd;
long id;
long timeout;
long lngData2;
char title;
|
by: Mark Ingalls |
last post by:
Hello Everyone,
I'm trying to send a text string to a dialog edit control using
SendMessage and WM_SETTEXT and cannot get it working correctly.
Here is the declaration of the function:
...
|
by: Necromis |
last post by:
Ok, I have gotten my head around things better regarding SendMessage
and FindWindow functions. However, I am running into an issue with my
code still. The program I am working with is EXTRA! by...
|
by: Dr1ZZ |
last post by:
Hi,
I'm currently working on a bot for a game.
It works like this:
1: Take a picture of the current playing field
2: Do the calculations on what i gotta do (best move)
3: Use sendmessage...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| | |