请写出具体代码及api应用。谢谢

解决方案 »

  1.   

    用spy++查找类名,然后用setwindowlong
      

  2.   

    楼上,能不能详细点啊setwindowlong 是什么用啊。。怎么实现那个按钮的单击操作啊?
      

  3.   

    还有,我不想用spy++获得得类名。而要用程序自已去获得类名,怎么做?
      

  4.   

    可以先用FindWindow找到你想要控制的窗口。
    我记得好像QQ的按钮,好像都有快捷键,你想实现按钮的单击,只需要用SendMessage向这个窗口发送相应的快捷键的虚拟键值。
      

  5.   

    FindWindow VB声明 
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 
    说明 
    寻找窗口列表中第一个符合指定条件的顶级窗口(在vb里使用:FindWindow最常见的一个用途是获得ThunderRTMain类的隐藏窗口的句柄;该类是所有运行中vb执行程序的一部分。获得句柄后,可用api函数GetWindowText取得这个窗口的名称;该名也是应用程序的标题) 
    返回值 
    Long,找到窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastError 
    参数表 
    参数 类型及说明 
    lpClassName String,指向包含了窗口类名的空中止(C语言)字串的指针;或设为零,表示接收任何类 
    lpWindowName String,指向包含了窗口文本(或标签)的空中止(C语言)字串的指针;或设为零,表示接收任何窗口标题 
    注解 
    很少要求同时按类与窗口名搜索。为向自己不准备参数传递一个零,最简便的办法是传递vbNullString常数
     
    示例 
    Dim hw&, cnt&
    Dim rttitle As String * 256
    hw& = FindWindow("ThunderRT5Main", vbNullString) ' ThunderRTMain under VB4
    cnt = GetWindowText(hw&, rttitle, 255)
    MsgBox Left$(rttitle, cnt), 0, "RTMain title" 
    FindWindowEx VB声明 
    Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long 
    说明 
    在窗口列表中寻找与指定条件相符的第一个子窗口 
    返回值 
    Long,找到的窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastError 
    参数表 
    参数 类型及说明 
    hWnd1 Long,在其中查找子的父窗口。如设为零,表示使用桌面窗口(通常说的顶级窗口都被认为是桌面的子窗口,所以也会对它们进行查找) 
    hWnd2 Long,从这个窗口后开始查找。这样便可利用对FindWindowEx的多次调用找到符合条件的所有子窗口。如设为零,表示从第一个子窗口开始搜索 
    lpsz1 String,欲搜索的类名。零表示忽略 
    lpsz2 String,欲搜索的标题。零表示忽略 
    'New Start-button
    Const WS_CHILD = &H40000000
    Const WM_LBUTTONDOWN = &H201
    Const WM_LBUTTONUP = &H202
    Const SW_HIDE = 0
    Const SW_NORMAL = 1
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Dim tWnd As Long, bWnd As Long, ncWnd As Long
    Private Sub Form_Load()
        'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim R As RECT
        'Get the taskbar's window handle
        tWnd = FindWindow("Shell_TrayWnd", vbNullString)
        'Get the start-button's window handle
        bWnd = FindWindowEx(tWnd, ByVal 0&, "BUTTON", vbNullString)
        'Get the start button's position
        GetWindowRect bWnd, R
        'Create a new button
        ncWnd = CreateWindowEx(ByVal 0&, "BUTTON", "Hello !", WS_CHILD, 0, 0, R.Right - R.Left, R.Bottom - R.Top, tWnd, ByVal 0&, App.hInstance, ByVal 0&)
        'Show our button
        ShowWindow ncWnd, SW_NORMAL
        'Hide the start button
        ShowWindow bWnd, SW_HIDE
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'show the start button
        ShowWindow bWnd, SW_NORMAL
        'destroy our button
        DestroyWindow ncWnd
    End Sub