This uses the inbuilt compilers in Windows 10 - there are three VB.NET compilers and three C# compilers - just copy each text file into the same folder and double click the batch file to make the program.
Window Manipulation Posts
REM GetWindowRect.bat
REM This file compiles GetWindowRect.vb to GetWindowRect.exe
REM GetWindowRect.exe reports on Windows position
REM To use
REM GetWindowRect <Window Title>
REM EG
REM GetWindowRect Untitled - Notepad
REM
REM Change /target:exe to /target:winexe and uncomment the
REM msgbox line in main file to make it a non console program
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:exe /out:"%~dp0\GetWindowRect.exe" "%~dp0\GetWindowRect.vb"
pause
'GetWindowRect.vb
imports System.Runtime.InteropServices
Public Module GetWindowRect
_
Private Structure RECTL
Public Left As UInt32
Public Top As UInt32
Public Right As UInt32
Public Bottom As UInt32
End Structure
Private Declare Function GetWindowRect Lib "User32" (ByVal hWnd as IntPtr, ByRef Rect as RectL) as Integer
Public Declare UNICODE Function FindWindowW Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Sub Main
On Error Resume Next
Dim hWindows as IntPtr
Dim Ret as Integer
hwindows = FindWindowW(vbNullString, Command())
If hwindows = 0 then
Msgbox(Command() & " cannot be found.")
Else
Dim x as RectL
Ret = GetWindowRect(hWindows, x)
If Ret = 0 Then
MsgBox("GetWindowRect Error " & Err.LastDllError)
Else
'Uncomment the MsgBox line if using as non console program
'Msgbox(x.left & " " & x.top & " " & x.right & " " & x.bottom)
Console.Writeline(x.left & " " & x.top & " " & x.right & " " & x.bottom)
End If
End If
End Sub
End Module
No comments:
Post a Comment