整了N天的坎终于迈过去了

         整了好多天的双击listbox的某一项终于整出来了,在这里保存一下

模块:

        Imports System.Runtime.InteropServices
Imports System
Imports System.IO
Imports System.Text
Imports System.Math
Module Module1
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Integer
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Integer) As Integer
    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
    Public Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    Public Const WM_USER As Integer = &H400
    Public Const LB_GETCOUNT As Integer = (WM_USER + 12)
    Public Const LB_SETCURSEL As Integer = &H186
    Public Const LB_GETCURSEL As Integer = &H188
    Public Const WM_LBUTTONDOWN As Integer = &H201
    Public Const WM_LBUTTONUP As Integer = &H202
    Public Const WM_LBUTTONDBLCLK As Integer = &H203
    Public WinHandle As Integer
    Public PanelHandle As Integer
    Public LVHandle As Integer
    Public LVHandle1 As Integer
End Module


 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        WinHandle = FindWindow(vbNullString, "金未来智能标记系统2010 - 中正金码 标记专家 -[脱机]")
        SetForegroundWindow(WHandle)
        'MessageBox.Show(WinHandle)
        If WinHandle <> 0 Then
            PanelHandle = FindWindowEx(WinHandle, vbNullString, "TPanel", vbNullString)
            PanelHandle = FindWindowEx(WinHandle, PanelHandle, "TPanel", vbNullString)
            ' MessageBox.Show(PanelHandle)
            If PanelHandle <> 0 Then
                LVHandle1 = FindWindowEx(PanelHandle, 0, "TListBox", vbNullString)
                'MessageBox.Show(LVHandle1)
                If LVHandle1 <> 0 Then
                    SendMessage(LVHandle1, LB_SETCURSEL, 3, 0)
                    Dim ID As Integer = SendMessage(LVHandle1, LB_GETCURSEL, 0, 0)
                    Dim x As Integer = 2
                    Dim y As Integer = ID * 20
                    SendMessage(LVHandle1, WM_LBUTTONDBLCLK, 1, (y << 16) + x)
                End If
            End If
        End If
    End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值