If you’r OS is Windows you can always use Windows API functions with LibreOffice Basic.
With the functions below you can retrieve and manipulate almost everything that happens on your screen.
REM ***** BASIC *****
Option VBASupport 1
Private Declare Function GetCursorPos Lib "user32" ( _
ByRef lpPoint As POINT) As Long
Private Declare Function GetWindowRect Lib "user32" ( _
ByVal hWnd As Long, ByRef lpRect As RECT) As Long
Private Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" ( _
ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Declare Function GetDC Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" ( _
ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Const LOGPIXELSX = 88
Private Const LOGPIXELSY = 90
Private Const TwipsPerInch = 1440
Type POINT
X As Long
Y As Long
End Type
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Const LOGPIXELSX = 88
Const LOGPIXELSY = 90
Const TwipsPerInch = 1440
Sub ScreenRes()
Dim w As Long, h As Long
w = GetSystemMetrics32(0) ' width in points
h = GetSystemMetrics32(1) ' height in points
MsgBox w & " " & h
Dim Pixels As POINT
Pixels = TwipsToPixels(w, h)
MsgBox Pixels.X & " " & Pixels.Y
End Sub
Function TwipsToPixels(ByVal X As Long, ByVal Y As Long) As POINT
Dim ScreenDC As Long
Dim Pixels As POINT
ScreenDC = GetDC(0)
' Convert twips to pixels
Pixels.X = X / TwipsPerInch * GetDeviceCaps(ScreenDC, LOGPIXELSX)
Pixels.Y = Y / TwipsPerInch * GetDeviceCaps(ScreenDC, LOGPIXELSY)
ReleaseDC 0, ScreenDC
TwipsToPixels = Pixels
End Function
Unfortunately, I have no experience with non-MS operating systems or non-PC devices.