Problems with Post/SendMessage to Diablo with c# menu

User Tag List

Results 1 to 2 of 2
  1. #1
    peterk's Avatar Private
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with Post/SendMessage to Diablo with c#

    Hi,

    i just begin to write my own "utility" for diablo 3 in C# and got an unexpected problem.

    if i use SendMessage for the left or the right mouse button anything works. if i use the middle mouse button, the x/y coords are ignored and the position of the real mouse pointer is taken instead :confused:. PostMessage give the same results. (MiddleMouseButton is bind to move in diablo).

    Code:
    public void MMouseClick(short x, short y)
    {
      IntPtr lParam = (IntPtr)((x & 0xFFFF) | ((y & 0xFFFF) << 16));
      const uint WM_MBUTTONDOWN = 0x0207;
      const uint WM_MBUTTONUP = 0x0208;
      SendMessage(hwnd, WM_MBUTTONDOWN, IntPtr.Zero, lParam);     // hwnd is an instance-var
      System.Threading.Thread.Sleep(50);
      SendMessage(hwnd, WM_MBUTTONUP, IntPtr.Zero, lParam);
    }
    Peter

    Problems with Post/SendMessage to Diablo with c#
  2. #2
    peterk's Avatar Private
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i created a little demo, i can't believe that i am the only person with this problem.
    the attachment is this source + gui with 4 buttons. you need visual c# to compile.
    if you run it, set diablo to 800*600 windowed, i just click static screen positions.

    if i change the 0x0207 to 0x0201 and 0x0208 to 0x0202 to use the left mouse button it works, but i want the middle button

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            IntPtr hwnd;
    
            [DllImport("user32")]
            static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
            [DllImport("user32.dll")]
            public static extern IntPtr SendMessage(IntPtr hwnd, uint message, IntPtr wParam, IntPtr lParam);
    
            public Form1()
            {
                InitializeComponent();
                hwnd = FindWindow(null, "Diablo III");
            }
    
            public void MMouseClick(short x, short y)
            {
                IntPtr lParam = (IntPtr)((x & 0xFFFF) | ((y & 0xFFFF) << 16));
                const uint WM_MBUTTONDOWN = 0x0207;                 // 0x0201 = left, 0x0204 = right, 0x0207 = middle
                const uint WM_MBUTTONUP = 0x0208;                   // 0x0202 = left, 0x0205 = right, 0x0208 = middle
                SendMessage(hwnd, WM_MBUTTONDOWN, IntPtr.Zero, lParam);
                System.Threading.Thread.Sleep(100);
                SendMessage(hwnd, WM_MBUTTONUP, IntPtr.Zero, lParam);
            }
    
            private void north_Click(object sender, EventArgs e)
            {
                MMouseClick(400, 200);
            }
    
            private void south_Click(object sender, EventArgs e)
            {
                MMouseClick(400, 400);
            }
    
            private void west_Click(object sender, EventArgs e)
            {
                MMouseClick(300, 300);
            }
    
            private void east_Click(object sender, EventArgs e)
            {
                MMouseClick(500, 300);
            }
        }
    }


    Peter
    Attached Files Attached Files

Similar Threads

  1. Having problems with your Configs? Post your problem here!
    By Mango Jerry in forum WoW EMU Guides & Tutorials
    Replies: 17
    Last Post: 04-07-2009, 05:53 AM
  2. [ArcEmu] Having problems with your Configs? Post your problem here!
    By Mango Jerry in forum WoW EMU Guides & Tutorials
    Replies: 0
    Last Post: 12-29-2008, 07:11 PM
All times are GMT -5. The time now is 03:53 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search