java 如何获取活动窗口的大小 10
我是想根据句柄来获得的可是我只知道怎么获得句柄不知道怎么用importambitui.RobotWindow.User32;importambitui.RobotWind...
我是想根据句柄来获得的可是我只知道怎么获得句柄不知道怎么用
import ambitui.RobotWindow.User32;
import ambitui.RobotWindow.W32API;
W32API.HWND hwnd = User32.INSTANCE.FindWindow(0, "VLC media player");//获得VLC media player窗体句柄后想获得它的窗口大小怎么弄
我查了下发现可以用BOOL GetWindowRect(HWND hWnd,LPRECT lpRect);函数获取,可是JAVA本身没有此函数,需要导入什么包么 展开
import ambitui.RobotWindow.User32;
import ambitui.RobotWindow.W32API;
W32API.HWND hwnd = User32.INSTANCE.FindWindow(0, "VLC media player");//获得VLC media player窗体句柄后想获得它的窗口大小怎么弄
我查了下发现可以用BOOL GetWindowRect(HWND hWnd,LPRECT lpRect);函数获取,可是JAVA本身没有此函数,需要导入什么包么 展开
1个回答
2015-07-02
展开全部
'VB获得活动窗口标题、位置、大小
'运行后,在form上print当前活动窗口信息
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Me.AutoRedraw = True
Timer1.Interval = 2000
Timer1.Enabled = True
End Sub
Sub Timer1_Timer()
Dim p As RECT
Dim h As Long
Dim str1 As String
h = GetActiveWindow '获得活动窗口句柄
str1 = String(255, 0)
GetWindowText h, str1, 255 '获得标题
GetWindowRect h, p '获得窗口位置、大小
Print "窗口标题:" & Left(str1, InStr(str1, Chr(0)) - 1) & " 窗口位置:Left=" & p.Left & " Top=" & p.Top & " 大小是:" & p.Right - p.Left & "X" & p.Bottom - p.Top
End Sub
'运行后,在form上print当前活动窗口信息
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Me.AutoRedraw = True
Timer1.Interval = 2000
Timer1.Enabled = True
End Sub
Sub Timer1_Timer()
Dim p As RECT
Dim h As Long
Dim str1 As String
h = GetActiveWindow '获得活动窗口句柄
str1 = String(255, 0)
GetWindowText h, str1, 255 '获得标题
GetWindowRect h, p '获得窗口位置、大小
Print "窗口标题:" & Left(str1, InStr(str1, Chr(0)) - 1) & " 窗口位置:Left=" & p.Left & " Top=" & p.Top & " 大小是:" & p.Right - p.Left & "X" & p.Bottom - p.Top
End Sub
追问
在JAVA里怎么弄是不是要弄什么JNA具体怎么弄
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询