| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1384 人关注过本帖
标题:vb6设置为后台模式,调用大漠插件后台找字、后台模拟鼠标点击?这段代码为何 ...
只看楼主 加入收藏
niyongjun
Rank: 1
等 级:新手上路
帖 子:12
专家分:4
注 册:2013-12-1
结帖率:0
收藏
 问题点数:0 回复次数:0 
vb6设置为后台模式,调用大漠插件后台找字、后台模拟鼠标点击?这段代码为何执行不了?
我想实现的是鼠标键盘对指定窗口在后台模式下操作,不影响前台的键盘鼠标的操作。
买了一个程序源码例子,运行不起。不知道是什么问题,跪求高手指点。谢谢
附程序源码

API声明
mports System.Runtime.InteropServices

Module Module1
    Public Declare Function GetLastError Lib "kernel32" Alias "GetLastError" () As Integer

    Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Integer)

    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As Integer) As Boolean
    End Function

    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Function FindWindow( _
     ByVal lpClassName As String, _
     ByVal lpWindowName As String) As Integer
    End Function

    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Module



Public Class Form1
Implements Dm  '定义大漠
    Public Dm As Object '创建大漠对象
    Private Const WM_LBUTTONDOWN = &H201 '窗口中按下鼠标左键
    Private Const WM_LBUTTONUP = &H202 '窗口中松开鼠标左键
    Private Const WM_MOUSEMOVE = &H200 '窗口中移动鼠标
    Private Const WM_RBUTTONDOWN = &H204 '窗口中按下鼠标右键
    Private Const WM_RBUTTONUP = &H205 '窗口中松开鼠标右键
    Private Const WM_MOUSEWHEEL = &H20A '鼠标滚轮
    Private Const WM_NCLBUTTONDOWN = &HA1 '窗口标题栏中按下鼠标左键
    Private Const WM_NCLBUTTONUP = &HA2 '窗口标题栏中左开鼠标左键
    Private Const WM_NCMOUSEMOVE = &HA0  '窗口标题栏中移动鼠标
    Private Const WM_NCRBUTTONDOWN = &HA4 '窗口标题栏中按下鼠标右键
    Private Const WM_NCRBUTTONUP = &HA5 '窗口标题栏中松开鼠标右键

    Dim hwnd As Long
    Dim hwnd1 As IntPtr
    Dim zbc
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dm = CreateObject("dm.dmsoft")  '对象实例化
        Dm.SetDict(0, "D:\我的文档\Visual Studio 2010  \Projects\WindowsApplication1\st10h.txt")  '字库文件地址

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim intX = Nothing
        Dim intY = Nothing
        Dim der
        Dim wMsg As Long, wParam As Long
        Dim xx As Integer
        Dim yy As Integer
        Dim lParam As Integer

        wParam = 1
        wMsg = WM_LBUTTONDOWN '左键按下消息
        ''   hwnd = Dm.FindWindow("WindowsForms10.Window.8.app.0.33c0d9d", "API浏览器")
        '' Dm.BindWindow(hwnd, "normal", "normal", "normal", 0)
        ''  hwnd1 = FindWindow("WindowsForms10.Window.8.app.0.33c0d9d", "API浏览器")
        Dm.FindStr(0, 0, 800, 800, "我的电脑", "ffffff-000000", 1, intX, intY)  '查找桌面"我的电脑"
        xx = intX + 10
        yy = intY
        lParam = yy * 65536 + xx
        '' der = PostMessage(65672, WM_MOUSEMOVE, 0, lParam) '发送消息

        Sleep(1000)
        ''  Dm.moveto(intX + 10, intY)
        Sleep(1000)
        PostMessage(65672, 513, 1, lParam) '发送消息
搜索更多相关主题的帖子: ByVal 鼠标 窗口 Integer Private 
2021-07-03 21:14
快速回复:vb6设置为后台模式,调用大漠插件后台找字、后台模拟鼠标点击?这段代 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016535 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved