| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 333 人关注过本帖
标题:后台点击代码,不报错,也没点击,求改
只看楼主 加入收藏
w327555162
Rank: 2
等 级:论坛游民
帖 子:45
专家分:43
注 册:2011-1-4
结帖率:85.71%
收藏
 问题点数:0 回复次数:0 
后台点击代码,不报错,也没点击,求改
Public Class Form1
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    '常量声明   
    Private Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_LBUTTONUP = &H202
    Private Const WM_MBUTTONDBLCLK = &H209
    Private Const WM_MBUTTONDOWN = &H207
    Private Const WM_MBUTTONUP = &H208
    Private Const WM_RBUTTONDBLCLK = &H206
    Private Const WM_RBUTTONDOWN = &H204
    Private Const WM_RBUTTONUP = &H205
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim lpClassName As String, lpWindowName As String, hWndX As Long
        lpClassName = "XLMAIN" '窗口的类名   
        lpWindowName = "Microsoft Excel - 111.xls" '窗口的标题
        hWndX = FindWindow(lpClassName, lpWindowName) '这一步获得窗口的句柄,发送消息时需要   
        Dim wMsg As Long, wParam As Long, lParam As Long, Rx As Long, xx As Integer, yy As Integer
        xx = 200 '点击的x坐标   
        yy = 300 '点击的y坐标   
        wMsg = WM_LBUTTONDOWN '左键按下消息   
        wParam = 1
        lParam = yy * 65536 + xx
        Call PostMessage(hWndX, wMsg, wParam, lParam) '发送消息   
        Sleep(300)
        wMsg = WM_LBUTTONUP '左键抬起消息   
        wParam = 1
        lParam = yy * 65536 + xx
        Call PostMessage(hWndX, wMsg, wParam, lParam) '发送消息

    End Sub



End Class
搜索更多相关主题的帖子: 声明 
2012-10-24 09:25
快速回复:后台点击代码,不报错,也没点击,求改
数据加载中...
 
   



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

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