SendMessage和WM_MOUSEMOVE/WM_LBUTTONDOWN-完全没有结果吗? [英] SendMessage and WM_MOUSEMOVE/WM_LBUTTONDOWN - no result at all?

查看:143
本文介绍了SendMessage和WM_MOUSEMOVE/WM_LBUTTONDOWN-完全没有结果吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家晚上好,
这是我已经尝试很长时间了..我已经阅读了大约500个有关此问题的网站/论坛帖子(感觉像是500 :)),但是我_never_知道了它可以正常工作.

我正在尝试在背景窗口中单击特定位置.例如最小化记事本,其他应用或游戏时.

这是我现在得到的代码..(只是其中的一部分,我还有很多,但是它已注释,并且也不起作用):

good evening everyone,
here's something i have been trying to accomplish for a very long time already.. i have read around 500 websites/forum posts about this already (felt like 500 :)) but i _never_ got it to work.

i'm trying to click on a specific position in a background window.. like when notepad, another app or a game is minimized.

this is the code i've got now.. (just parts of it, i have a lot more but its commented and not working either):

    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

    Dim DaWord As Long
    DaWord = MakeDWord(800, 600) 
    Const WM_MOUSEMOVE = &H200
    Const WM_LBUTTONDOWN = &H201
    Const WM_LBUTTONUP = &H202

            SendMessage(FindWindow(Nothing, "App"), WM_LBUTTONDOWN, 1&, DaWord)
            SendMessage(FindWindow(Nothing, "App"), WM_LBUTTONUP, 1&, DaWord)

    Function MakeDWord(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long
        MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&)
    End Function


这是我用于测试的更多垃圾代码..但没有任何效果..


and this is some more junk code i used for testing.. but nothing has worked..

                SendMessage(hwnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, MakeLParam(Point.X + 30, Point.Y + 30))
                SendMessage(hwnd, WM_LBUTTONDOWN, WM_LBUTTONUP, MakeLParam(Point.X + 30, Point.Y + 30))
                SendMessage(hwnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, MakeDWord(Point.X + 30, Point.Y + 30))
                SendMessage(hwnd, WM_LBUTTONDOWN, WM_LBUTTONUP, MakeDWord(Point.X + 30, Point.Y + 30))
                SendMessage(hwnd, WM_LBUTTONUP, WM_LBUTTONDOWN, MakeDWord2(Point.X + 30, Point.Y + 30))
                SendMessage(hwnd, WM_LBUTTONUP, WM_LBUTTONUP, MakeDWord2(Point.X + 30, Point.Y + 30))

    'SendMessage(hwnd, WM_MOUSEMOVE, WM_LBUTTONDOWN, MakeLParam(Point.X + 30, Point.Y + 30))
    'SendMessage(hwnd, WM_MOUSEMOVE, WM_LBUTTONUP, MakeLParam(Point.X + 30, Point.Y + 30))
    'SendMessage(hwnd, WM_MOUSEMOVE, WM_LBUTTONDOWN, MakeDWord(Point.X + 30, Point.Y + 30))
    'SendMessage(hwnd, WM_MOUSEMOVE, WM_LBUTTONUP, MakeDWord(Point.X + 30, Point.Y + 30))
    'SendMessage(hwnd, WM_MOUSEMOVE, WM_LBUTTONDOWN, MakeDWord2(Point.X + 30, Point.Y + 30))
    'SendMessage(hwnd, WM_MOUSEMOVE, WM_LBUTTONUP, MakeDWord2(Point.X + 30, Point.Y + 30))

    Shared Function MakeLParam(ByVal LoWord As Integer, ByVal HiWord As Integer) As IntPtr
        Return (HiWord << 16) Or (LoWord And &HFFFF)
    End Function

    'Const WM_MOUSEMOVE = &H200
    'Const WM_LBUTTONDOWN = &H201
    'Const WM_LBUTTONUP = &H202
    'Const WM_LBUTTONDBLCLK = &H203
    'Const WM_RBUTTONDOWN = &H204
    'Const WM_RBUTTONUP = &H205
    'Const WM_RBUTTONDBLCLK = &H206
    'Const MK_LBUTTON = &H1
    'Const MK_RBUTTON = &H2



对于此=>



i would be very glad for any help or code examples on this =)

推荐答案

的任何帮助或代码示例,我将非常高兴.您发布的代码是为VB6或更早版本编写的版本.假设您使用的是.NET版本的VB,则首先需要对声明进行调整.您可能还需要查看 SendInput 函数.
The code you posted is written for VB6 or earlier versions. Assuming you're using a .NET version of VB, you first need to adapt your declarations to that. You may also want to look at the SendInput function.


这篇关于SendMessage和WM_MOUSEMOVE/WM_LBUTTONDOWN-完全没有结果吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆