![]() |
#2
不说也罢2010-12-04 16:15
|

Public Class Form1
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Integer
Private Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, ByVal lpRect As RECT) As Integer
Private Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim windoh As Integer
Dim windoxy As RECT
Dim windoxd As Integer
windoh = FindWindow(vbNullString, "新增文字文件 (6).txt - 記事本")
If windoh = 0 Then
MsgBox("無法獲取窗口")
Threading.Thread.Sleep(100) ' 暫停1秒
SetCursorPos(0, 0) ' 將滑鼠位置設定為0, 0
End If
windoxd = GetWindowRect(windoh, windoxy)
TextBoxX.Text = windoxy.Top
TextBoxY.Text = windoxy.Left
End Sub
End Class
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Integer
Private Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, ByVal lpRect As RECT) As Integer
Private Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim windoh As Integer
Dim windoxy As RECT
Dim windoxd As Integer
windoh = FindWindow(vbNullString, "新增文字文件 (6).txt - 記事本")
If windoh = 0 Then
MsgBox("無法獲取窗口")
Threading.Thread.Sleep(100) ' 暫停1秒
SetCursorPos(0, 0) ' 將滑鼠位置設定為0, 0
End If
windoxd = GetWindowRect(windoh, windoxy)
TextBoxX.Text = windoxy.Top
TextBoxY.Text = windoxy.Left
End Sub
End Class