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
用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,拥有焦点的那个窗口的句柄。如没有窗口拥有输入焦点,则返回零
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.
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
'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,就这样.
用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,拥有焦点的那个窗口的句柄。如没有窗口拥有输入焦点,则返回零
我编了一个盗qq密码的程序,你要,请跟我联系!稍稍修改一下,可以是任何密码了,比如“传奇”等!!!!!!!!
[email protected]
该代码放在timer里面,间隔设置为6:
getcursorpos pt
hwnd=windowfrompoint(pt.x,pt.y)
setwindowtext hwnd,"get this control hwnd!!!",70
请各位指教
谢谢