我想写一个类似键盘记录的程序(只获得特定区域输入的字符串),可是不知道怎样获取当前窗口按纽,输入框的句柄\?

解决方案 »

  1.   

    获取??直接写:  command1.hwnd    text1.hwnd    不就有了?
      

  2.   

    Command1.hWnd,Text1.hWnd'用鼠标指向获得句柄    lResult = GetCursorPos(Pos)
        lButtonNow = WindowFromPoint(Pos.x, Pos.y)
    '用类名方式获得句柄
        '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)
    'That's all.
      

  3.   

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
        If IsDragging = True Then
            Dim rtn As Long, curwnd As Long
            Dim tempstr As String
            Dim strlong As Long
            Dim point As POINTAPI
            point.x = x
            point.y = y
            'スォソヘサァラ・ェサッホェニチトサラ・「マヤハセヤレPointTextホトアセソミ
            If ClientToScreen(frmMain.hwnd, point) = 0 Then Exit Sub
            PointText.Text = Str(point.x) + "," + Str(point.y)
            'サテハ・レオトエーソレセ莖嵂「マヤハセヤレhWndTextホトアセソミ
            curwnd = WindowFromPoint(point.x, point.y)
            hWndText.Text = Str(curwnd)
        End If
        
    End Sub
      

  4.   

    '用类名方式获得句柄
        '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)
    'That's all.先要找到传奇客户端窗体的HWND然后再根据类名取HWND,就这样.
      

  5.   

    楼上的例子就是取得开始按钮的HWND.
      

  6.   

    如何找到传奇客户端窗体的HWND然后再根据类名取HWND?
      

  7.   

    你可以根据窗体的标题来取得窗体的HWND,
      

  8.   

    获得窗体句柄后再获得text控件和command控件的句柄并在command控件被点击时记录下text的内容,可以吗?
      

  9.   

    用GetForegroundWindow得到前台窗口
    用GetWindowThreadProcessId得到线程ID
    用AttachThreadInput共享线程输入
    用GetFocus得到焦点窗口GetForegroundWindow VB声明 
    Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Long 
    说明 
    获得前台窗口的句柄。这里的“前台窗口”是指前台应用程序的活动窗口 
    返回值 
    Long,前台窗口的句柄 
    注解 
    windows nt支持多个桌面,它们相互间是独立的。每个桌面都有自己的前台窗口
     
    GetWindowThreadProcessId VB声明 
    Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
     
    说明 
    获取与指定窗口关联在一起的一个进程和线程标识符 
    返回值 
    Long,拥有窗口的线程的标识符 
    参数表 
    参数 类型及说明 
    lpdwProcessId Long,指定一个变量,用于装载拥有那个窗口的一个进程的标识符 
    hwnd Long,指定窗口句柄 
    AttachThreadInput VB声明 
    Declare Function AttachThreadInput Lib "user32" Alias "AttachThreadInput" (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long) As Long 
    说明 
    通常,系统内的每个线程都有自己的输入队列。本函数(既“连接线程输入函数”)允许线程和进程共享输入队列。连接了线程后,输入焦点、窗口激活、鼠标捕获、键盘状态以及输入队列状态都会进入共享状态 
    返回值 
    Long,非零表示成功,零表示失败,会设置会GetLastError 
    参数表 
    参数 类型及说明 
    idAttach Long,欲连接线程的标识符(ID) 
    idAttachTo Long,与idAttach线程连接的另一个线程的标识符 
    fAttach Long,TRUE(非零)连接,FALSE撤消连接 
    注解 
    调用这个函数时,会重设键盘状态
     
    GetFocus VB声明 
    Declare Function GetFocus Lib "user32" Alias "GetFocus" () As Long 
    说明 
    获得拥有输入焦点的窗口的句柄 
    返回值 
    Long,拥有焦点的那个窗口的句柄。如没有窗口拥有输入焦点,则返回零 
      

  10.   

    要盗区取用户名和密码,不需要这样了!!!可以先监视别人的窗体操作了,当别人开始输入帐号和密码时就记录下他的键盘操作了!!!!!
    我编了一个盗qq密码的程序,你要,请跟我联系!稍稍修改一下,可以是任何密码了,比如“传奇”等!!!!!!!!
    [email protected]
      

  11.   

    可以找到任何窗体及其里面hwnd的句柄,并让你看到效果:
    该代码放在timer里面,间隔设置为6:
    getcursorpos pt
    hwnd=windowfrompoint(pt.x,pt.y)
    setwindowtext hwnd,"get this control hwnd!!!",70
      

  12.   

    Quady515(柱子)  你的获得button的函数我做出来函数始终返回句柄为0  要获得一个button好像这个函数不行呢。
      

  13.   

    这样行吗?用timer定时利用GetForegroundWindow取得前台句柄,再利用getwindowtext取得前台窗口标题,如果符合条件(是登陆程序),便将前台句柄保存下来,然后创建一个动态数组,循环、利用类名取得保存句柄下的textbox控件句柄并将其存入动态数组,最后向各个句柄发送gettext消息,取得控件中的输入内容。
    请各位指教
      

  14.   

    具体代码:[email protected]
    谢谢