
Originally Posted by
Slyke
...The part that i'm missing is how to get the active window's top, left, width and height ...
Would this work for you?
VB Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hWnd As Long, lpRect As RECT) As Long
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim lWnd As Long
Dim rct As RECT
lWnd = GetActiveWindow()
GetWindowRect lWnd, rct
Debug.Print "Left = " & rct.Left * Screen.TwipsPerPixelX
Debug.Print "Top = " & rct.Top * Screen.TwipsPerPixelY
Debug.Print "Height = " & (rct.Bottom - rct.Top) * Screen.TwipsPerPixelX
Debug.Print "Width = " & (rct.Right - rct.Left) * Screen.TwipsPerPixelY
End Sub