Desktop.windows give only active window [solved]

Post

Posted
Rating:
#1 (In Topic #752)
Trainee
I'm trying to align a transparent window on top of another window (a mediaplayer window) and therefore it would be very helpful to get the X and Y coordinates for both windows.
 
I found a code example in the Gambas Book (gambas-buch.de) chapter 15.4 which does exactly what I want.

Code

Public Sub Button1_Click()

  Dim dtWindow As DesktopWindow
  Desktop.Windows.Refresh()
 
  For Each dtWindow In Desktop.Windows
    If dtWindow.SkipTaskbar = False Then
       Print "Window.Name = \"" & dtWindow.Name & "\" , X = " & dtWindow.X & " , Y = " & dtWindow.Y
    Endif
  Next
 
End

The problem is that I only recieve the active window and nothing else. In the book they recieve all windows, not only the active one.
I have included gb.desktop and gb.desktop.x11.
Gambas version is 3.16.3 on Linux mint 20.1 Cinnamon.

Obviously I'm doing something wrong or missing some important stuff but what?

Ps Will be a measuring microscope when finished
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
that code works completely as expected for me on mint

[System]
Gambas=3.16.90 51cf626fa (bruces-patched)
OperatingSystem=Linux
Kernel=5.4.0-84-generic
Architecture=x86_64
Distribution=Linux Mint 20.2 Uma
Desktop=Cinnamon


Result
Window.Name = "Computer" , X = 256 , Y = 194
Window.Name = "MediaPlay" , X = 39 , Y = 328
Window.Name = "Gambas ONE - Post a reply — Mozilla Firefox" , X = 49 , Y = 76
Window.Name = "Startup.module - _aa 0.0.28 — Gambas 3 - DEVELOPMENT VERSION, USE AT YOUR OWN RISK!" , X = 147 , Y = 122

Did you try it without the "If dtWindow.SkipTaskbar" bit?

Code (gambas)

  1. Public Sub Button1_Click()
  2.  
  3.   Dim dtWindow As DesktopWindow
  4.   Desktop.Windows.Refresh()
  5.  
  6.   For Each dtWindow In Desktop.Windows
  7.        Print "Window.Name = \"" & dtWindow.Name & "\" , X = " & dtWindow.X & " , Y = " & dtWindow.Y
  8.   Next
  9.  
  10.  
Online now: Yes Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
Have a look at the attached program and see if that helps you.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Trainee
 Thank's a lot BruceSteers and Cogier for your answers.
I took a new computer, made a fresh Linux Mint 20.2 and a Gambas ppa:-install and now it works like a charm. I don't know what's wrong with the old computer but it's obviously local to that computer.
Have a nice day everyone!
Online now: No Back to the top

Post

Posted
Rating:
#5
Trainee
 And your example was really cool, Cogier.
Will see if I can use it together with the mediaplayer window.
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
I know a lot of gambas features requires x11 , if your other system uses wayland then various things will not work as expected.

That's about all i can think of.

I'm sure you'll figure it out.
:)
Online now: Yes Back to the top
1 guest and 0 members have just viewed this.