Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: calling a string variable in "proc.StartInfo.Arguments" Pin
Richard MacCutchan28-May-17 21:37
mveRichard MacCutchan28-May-17 21:37 
QuestionDeclaring a Generic Class Pin
Richard Andrew x6428-May-17 14:50
professionalRichard Andrew x6428-May-17 14:50 
AnswerRe: Declaring a Generic Class PinPopular
OriginalGriff28-May-17 19:28
mveOriginalGriff28-May-17 19:28 
GeneralRe: Declaring a Generic Class Pin
Richard Andrew x6429-May-17 2:09
professionalRichard Andrew x6429-May-17 2:09 
GeneralRe: Declaring a Generic Class Pin
OriginalGriff29-May-17 2:26
mveOriginalGriff29-May-17 2:26 
QuestionMessage Closed Pin
28-May-17 9:06
Member 1308759428-May-17 9:06 
AnswerRe: Why still get empty list? Pin
Pete O'Hanlon28-May-17 9:13
mvePete O'Hanlon28-May-17 9:13 
QuestionAbout the WM_LBUTTONDOWN Pin
Member 1322740128-May-17 6:15
Member 1322740128-May-17 6:15 
The question is simple, I have a code that's using the PostMessage function like so :

public enum WMessages : int
        {
            WM_MOUSEMOVE=                    0x0200,

            WM_LBUTTONDOWN = 0x201,
            WM_LBUTTONUP = 0x202,
            WM_RBUTTONDOWN = 0x0204,
            WM_RBUTTONUP = 0x0205,

            WM_KEYDOWN = 0x100,
            WM_KEYUP = 0x101,

            WH_KEYBOARD_LL = 13,
            WH_MOUSE_LL = 14,
        }
[DllImport("User32.Dll", EntryPoint = "PostMessageA")]
        static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
        private int MAKELPARAM(int p, int p_2)
        {
            return (p_2 * 0x10000 + p);
        }
        public void SendClick(WMessages type, Point pos, IntPtr hwnd)
        {
            switch (type)
            {
                case WMessages.WM_LBUTTONDOWN:
                    PostMessage(hwnd,
                        (int)0x201, 1,
                        MAKELPARAM(pos.X, pos.Y));//(IntPtr)((pos.Y << 16) | (pos.X & 0xFFFF)));
                    return;
                case WMessages.WM_LBUTTONUP:
                    PostMessage(hwnd,
                        (int)WMessages.WM_LBUTTONUP, 0, // <--(2) but you are telling to do WM_LBUTTONDOWN
                        MAKELPARAM(pos.X, pos.Y));//(IntPtr)((pos.Y << 16) | (pos.X & 0xFFFF)));
                    return;
                default:
                    return;
            }
        }


The only problem is that it clicks in a wrong place. For example, if i input the point 50,50 it'll click in 70,70 for example, offsetted to the window handle.

I wonder why it happens? Hope to get an answer.

Thanks in advance.

Example :

IntPtr atat = (IntPtr)0x00010870;
SendRClick(WMessages.WM_RBUTTONDOWN, new Point(50, 50), atat);
SendRClick(WMessages.WM_RBUTTONUP, new Point(50, 50), atat);


Edit :

I've found something interesting, apparently it happens only in 1 of my screens (I have 2), in the other one its not happening.

The screen that it happens in's resolution is 1920/1080, the screen that does it correctly's resolution is 1280/1024 (my main screen, does it correctly).

Edit 2 :

Also another thing that I've forgot to mention, the ratio between the resulted point to the inserted point is 1.5 in X and also in Y.

For example, if I've entered X=100,Y=100, it'll be resulted in 150 X and 150 Y offset from the window handle.

Edit 3 :

An alternative would be to devide the x and y by 1.5 and then it'll be multiplied again by default... but its not really an answer
AnswerRe: About the WM_LBUTTONDOWN Pin
Gerry Schmitz28-May-17 9:51
mveGerry Schmitz28-May-17 9:51 
AnswerRe: About the WM_LBUTTONDOWN Pin
raddevus29-May-17 4:42
mvaraddevus29-May-17 4:42 
QuestionPOST JSON Request to a RESTful service + server deployment Pin
Code_Project_127-May-17 9:07
Code_Project_127-May-17 9:07 
QuestionDislaying 3D model in C# winform Pin
Member 1301708227-May-17 0:11
Member 1301708227-May-17 0:11 
AnswerRe: Dislaying 3D model in C# winform Pin
Dave Kreskowiak27-May-17 4:45
mveDave Kreskowiak27-May-17 4:45 
AnswerRe: Dislaying 3D model in C# winform Pin
lmoelleb28-May-17 2:21
lmoelleb28-May-17 2:21 
GeneralRe: Dislaying 3D model in C# winform Pin
Member 1301708228-May-17 21:45
Member 1301708228-May-17 21:45 
QuestionHow to retrieve image from multiple folder from SharePoint Pin
Hamizah AHMAD TALHAH24-May-17 16:08
Hamizah AHMAD TALHAH24-May-17 16:08 
QuestionRe: How to retrieve image from multiple folder from SharePoint Pin
Richard MacCutchan24-May-17 23:24
mveRichard MacCutchan24-May-17 23:24 
AnswerRe: How to retrieve image from multiple folder from SharePoint Pin
Gerry Schmitz25-May-17 5:26
mveGerry Schmitz25-May-17 5:26 
QuestionDisplay a Message for Failure or Success C# Pin
Member 1321855223-May-17 9:55
Member 1321855223-May-17 9:55 
AnswerRe: Display a Message for Failure or Success C# Pin
Pete O'Hanlon23-May-17 21:04
mvePete O'Hanlon23-May-17 21:04 
GeneralRe: Display a Message for Failure or Success C# Pin
Member 1321855223-May-17 23:19
Member 1321855223-May-17 23:19 
GeneralRe: Display a Message for Failure or Success C# Pin
OriginalGriff23-May-17 23:27
mveOriginalGriff23-May-17 23:27 
GeneralRe: Display a Message for Failure or Success C# Pin
MadMyche25-May-17 15:57
professionalMadMyche25-May-17 15:57 
GeneralRe: Display a Message for Failure or Success C# Pin
Pete O'Hanlon25-May-17 20:59
mvePete O'Hanlon25-May-17 20:59 
GeneralRe: Display a Message for Failure or Success C# Pin
MadMyche26-May-17 2:31
professionalMadMyche26-May-17 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.