[Gambas-user] Test Screen.Available values

Martín mbelmonte at belmotek.net
Mon May 22 10:35:13 CEST 2023


Hi,

Perhaps the following code may be useful

' Gambas class file

Export

Static Public Sub Fix(o As Object, Optional s As Integer = -1)

   Dim x As Integer

   x = Screen(s)

   o.x = Screens[x].AvailableX + Screens[x].AvailableWidth / 2 - o.W / 2
   o.y = Screens[x].AvailableY + Screens[x].AvailableHeight / 2 - o.H / 2

End

Static Public Sub Shoot(o As Object, Optional s As Integer = -1, 
Optional sPath As String = "/tmp/bro.png", Optional iQua As Integer = 100)

   Dim x As Integer

   x = Screen(s)

   Desktop.Screenshot(Screens[x].X, Screens[x].Y, Screens[x].Width, 
Screens[x].Height).Save(sPath, iQua)

End

Static Private Function Screen(s As Integer) As Integer

   Dim n, b, x As Integer

   If s = -1 Then
     For n = 0 To Screens.Count - 1
       If Screens[n].AvailableWidth > b Then
         b = Screens[n].AvailableWidth
         x = n
       Endif
     Next
   Else
     If s < Screens.Count Then
       x = s
     Else
       x = 0
     Endif
   Endif

   Return x

End

Best regards

Martin.



More information about the User mailing list