ScreenShot

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Sunday 24th May 2020 9:17pm

Charlie,

I haven't yet had time to take a look at those books.

In the SelectArea app, I noticed that your version had a Horizontal Panel (in the FMain form) with the Select & Hint buttons. There was a Spring control placed between (connecting?) the 2 buttons. What does it do?

I'm now trying to get my SelectWindow app working (previous questions were on my SelectArea app). I fill various arrays (aWindowRect, aWindow) with elements from the DesktopWindow set of objects (which interestingly includes the what I think of as the Ubuntu Desktop which I ignore using the "If .VisibleName = "Desktop" And .Height = Screen.Height And .Width = Screen.Width Then Continue" code line below) using the FindWindows method you suggested in your last post. What does the SkipTaskbar property of the Desktop Window object actually mean?

Code: Select all

Public Sub Form_Open()
  Dim i As Integer
  Dim hDesktopWindow As DesktopWindow
  For Each i In Desktop.FindWindow(Null, Null, Null)
    hDesktopWindow = New DesktopWindow(i)
    With hDesktopWindow
      If .Minimized Then Continue
      If .VisibleName = "Desktop" And .Height = Screen.Height And .Width = Screen.Width Then Continue
      aWindow.Add(hDesktopWindow)
      Print "DesktopWindow: ", "Name=" & .Name, "VisibleName=" & .VisibleName, "Hex(i)=" & Hex(i)
      Print ".Id=" & .Id, "Left=" & .X, "Top=" & .Y, "Width=" & .Width, "Height=" & .Height
      aWindowVisibleName.Add(.VisibleName)
      aWindowRect.Add(.Geometry)
    End With
In the above code, the Minimized property doesn't seem to work properly always i.e. a DesktopWindow sometimes does not have its Mimimized property set even when it's minimised (this was picked up by the Print lines in the above code actually happening for a Terminal window). The Mimimized property was set correctly (and therefore its details not printed) for a Nautilus window which was minimised, and correctly another Nautilus window which was not minimised did have its details printed. I have attached the app's tar.gz in case you want to try it yourself.

I'm also intrigued by the FullScreen property of a DesktopWindow object. Would a FullScreen window cover the Launcher & Systray panels (e.g. when you run a video file in full screen 'mode')? Would its DesktpWindow details have a VisibleName property?

I have a DrawingAreaDesktop with Opacity=35 overlaying Ubuntu's desktop (as in the previous SelectArea app). This has a MouseUp event with some of its coding shown below. The problem is that if there are 2 windows overlapping then I want to select the window where the overlapping part is displayed on top (of Ubuntu's desktop). However, my code shown below only finds the first window in the aWindowRect array (the aWindow array contains all the DesktopWindow elements). Is there a way of cycling through these arrays to only select the DesktopWindow which is on top?

Code: Select all

For j = 0 To aWindowRect.Max
    If aWindowRect[j].Contains(Mouse.X, Mouse.Y) Then
      sWindowVisibleName = aWindowVisibleName[j]
      hWindowRect = aWindowRect[j]
      With hWindowRect
        iWindowLeft = .Left
        iWindowTop = .Top
        iWindowWidth = .Width
        iWindowHeight = .Height
      End With
      bWindowSelected = True
      Break
    Endif
  Next
Attachments
SelectWindow.tar.gz
(18.38 KiB) Downloaded 13 times
John

User avatar
cogier
Site Admin
Posts: 466
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Monday 25th May 2020 2:25pm

What does the SkipTaskbar property of the Desktop Window object actually mean?
If SkipTaskbar is set to True then when you open the window it will NOT appear on the taskbar. This is handy if your program opens more that one window and you don't want the taskbar filled up with your windows.
Would a FullScreen window cover the Launcher & Systray panels (e.g. when you run a video file in full screen 'mode')? Would its DesktpWindow details have a VisibleName property?
Yes it covers the whole screen. Have a look at the attached and the widow would have a name. Also have a look at here.
The problem is that if there are 2 windows overlapping
I really struggled with this one but finally came up with a terminal command that seems to work. See line 41 of FSelectWindow class in the attached and the 'Shell' command below. Also check out GetScreenShot().
For Each hWindow In aWindow
    If Mouse.ScreenX > hWindow.X - 20 And Mouse.ScreenX < hWindow.X + hWindow.Width And Mouse.ScreenY > hWindow.Y - 20 And Mouse.ScreenY < hWindow.Y + hWindow.Height Then
      Shell "wmctrl -a " & hWindow.Name
      Wait 0.25
      FMain.PictureBoxArea.Picture = hWindow.GetScreenshot()
      Break
    End If
  Next

I stripped your code down so some functionality might have been lost but it is working. I also made the form fully opaque as there is no need to draw on it when selecting a window.

I noticed that your version had a Horizontal Panel (in the FMain form) with the Select & Hint buttons. There was a Spring control placed between (connecting?) the 2 buttons. What does it do?
Have a look at the attached code, hopefully it will help. A Spring pushes away at both ends. Move the Springs around and resize the Form to see what happens. A Spring does the same as a control (e.g. a PictureBox) that has the Expand Property set to True.
Spring-0.0.1.tar.gz
(11.51 KiB) Downloaded 16 times
Fullscreen-0.0.1.tar.gz
(2.72 MiB) Downloaded 15 times
SelectWindow-CO-0.0.31.tar.gz
(17.85 KiB) Downloaded 15 times

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Monday 25th May 2020 7:30pm

Charlie,

Thanks for your hard work correcting my errors etc. You mentioned a farm somewhere. I found it but the response from it is extremely slow when I search it with no parameters: though could be due to my 5+ year old 8GB Barebones Celeron based PC or even my OpenReach's current slow internet connection. Where are the instructions for uploading apps into it? I've got some apps that might be of interest to put in it e.g. iRecorder which is a GUI front end to the get_iplayer terminal program, various apps for the Enigma & Lorenz machines used by Germany in WW2.

I'm still a little unclear about the Expanded property of a Form. Does it expand to the area of the usable desktop (i.e. excluding launch Panel & Systray) or the whole screen (i.e. including launch Panel & Systray)? If the latter, could the Desktop Drawing Area overlay the usable desktop?

I also noticed that the StartX of the Mouse class in the DrawingAreaDesktop (i.e. Drawing Area class) control's MouseDown event is 0 whereas the X property is properly set. Since there is no MouseDown event for the Mouse class, would that be the reason?
Have a look at the attached code, hopefully it will help. A Spring pushes away at both ends. Move the Springs around and resize the Form to see what happens. A Spring does the same as a control (e.g. a PictureBox) that has the Expand Property set to True.
I looked at your Spring app. I don't understand the use of various panels: the set 4,1,5 and the set 6,3,7. Why does each result in the middle panel (1 & 3) of each set becoming a line all the way across the form at runtime?
Also, I don't understand what's happening to the button positions for numbers 5 & 6. Why do they move to the form vertical edges?

Re the overlapping windows:
I really struggled with this one but finally came up with a terminal command that seems to work. See line 41 of FSelectWindow class in the attached and the 'Shell' command below. Also check out GetScreenShot().
For Each hWindow In aWindow
If Mouse.ScreenX > hWindow.X - 20 And Mouse.ScreenX < hWindow.X + hWindow.Width And Mouse.ScreenY > hWindow.Y - 20 And Mouse.ScreenY < hWindow.Y + hWindow.Height Then
Shell "wmctrl -a " & hWindow.Name
Wait 0.25
FMain.PictureBoxArea.Picture = hWindow.GetScreenshot()
Break
End If
Next
I think there are problems with the app as stripped down by you. The image shown in the FMain form's PictureBox includes a 'border' (from the desktop, typically part of another window) around the selected window: could this be due to the If line in the above code?. I've amended the app and put print statements back in to see what's going on. I removed the 'If .Desktop' and 'End If' lines in the FMain form's Open event as they stopped windows being stored in the aWindow: shown by results of the Print Statements. I also put back coding to draw a border around the selected desktop window (with a wait of 10 seconds) as I wanted to see which window was selected when I clicked in the overlapping area of 2 desktop windows: this will also be required in the StreamRecorder app which will use the SelectWindow & SelectArea forms & Class coding from the corresponding apps. However, I forgot until now to alter the Opacity setting back to 35 so that didn't work. Could you explain in detail what the 2 lines shown below do? IMO a window shoulld be selectable even if it is overlapped by another window provided that the overlap area is not clicked on: does that coding achieve that? I've been wondering if the Shaded property of the Desktop window object has anything to do with a window which is overlapped.

Code: Select all

If Mouse.ScreenX > hWindow.X - 20 And Mouse.ScreenX < hWindow.X + hWindow.Width And Mouse.ScreenY > hWindow.Y - 20 And Mouse.ScreenY < hWindow.Y + hWindow.Height Then
      Shell "wmctrl -a " & hWindow.Name
I took a look at the Wikibooks Programming Gambas from Zip. I liked the fact that it looked like a Reference manual. Whereas the other 4 book set is what I would call a Learning Manual/Guide (i.e. it doesn't cover everything in depth but it allows the beginner to get going: problem with that is, especially at my age, is forgetting the detail of topics and/or not knowing enough detail.
Attachments
SelectWindow-CO-JR.tar.gz
(17.83 KiB) Downloaded 13 times
John

User avatar
cogier
Site Admin
Posts: 466
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Tuesday 26th May 2020 5:49pm

Hi John,
You mentioned a farm somewhere...... Where are the instructions for uploading apps into it?
Menu Project > Publish will get you on the Farm. You can view the farm from Tools > Software farm or from Gambas.one here.
I'm still a little unclear about the Expanded property of a Form. Does it expand to the area of the usable desktop (i.e. excluding launch Panel & Systray) or the whole screen (i.e. including launch Panel & Systray)?
I think that the Form Expand will only work if the Form is embedded in another Control
I also noticed that the StartX of the Mouse class in the DrawingAreaDesktop (i.e. Drawing Area class) control's MouseDown event is 0 whereas the X property is properly set. Since there is no MouseDown event for the Mouse class, would that be the reason?
Yes
I looked at your Spring app. I don't understand the use of various panels: the set 4,1,5 and the set 6,3,7. Why does each result in the middle panel (1 & 3) of each set becoming a line all the way across the form at runtime?
Anything on the Form with the Arrangement set to Vertical, including the HBoxes (but not their contents), will expand to fill the Form horizontally including items 4, 1, 5, 3, 6 & 7. Put a button on the Form and see what happens.
Also, I don't understand what's happening to the button positions for numbers 5 & 6. Why do they move to the form vertical edges?
Everything in an HBox if forced to the left unless pushed by a control set to Expand or a Spring. So buttons 7 & 8 move to the left but button 9 is forced to the right by the Spring. This is NOT 'What You See Is What You Get'.
The image shown in the FMain form's PictureBox includes a 'border'
Well spotted, change the line to: -
FMain.PictureBoxArea.Picture = hWindow.GetScreenshot(False)
The 2 lines: -
If Mouse.ScreenX > hWindow.X - 20 And Mouse.ScreenX < hWindow.X + hWindow.Width And Mouse.ScreenY > hWindow.Y - 20 And Mouse.ScreenY < hWindow.Y + hWindow.Height Then
      Shell "wmctrl -a " & hWindow.Name
The first line detects if the hWindow is in the area that was 'Clicked' on. The 2nd line uses 'wmctrl' to 'Raise' the window. In Terminal type man wmctrl for more help.
...especially at my age...
I'm collecting my pension! :D

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Wednesday 27th May 2020 8:39am

Charlie,

Thanks for the info about the Gambas Farm. Do you find the same problem with Gambas Farm as I do: namely the slow response when scrolling down the app details after a search with no parameters set?

There's still a problem on 'overlapping' windows when trying to select a window. Below is shown a bit of my original post about it and your response:
IMO a window should be selectable even if it is overlapped by another window provided that the overlap area is not clicked on: does that coding achieve that? I've been wondering if the Shaded property of the Desktop window object has anything to do with a window which is overlapped.
If Mouse.ScreenX > hWindow.X - 20 And Mouse.ScreenX < hWindow.X + hWindow.Width And Mouse.ScreenY > hWindow.Y - 20 And Mouse.ScreenY < hWindow.Y + hWindow.Height Then
Shell "wmctrl -a " & hWindow.Name
The first line detects if the hWindow is in the area that was 'Clicked' on. The 2nd line uses 'wmctrl' to 'Raise' the window. In Terminal type man wmctrl for more help.
When I run the stripped down app, with 2 Nautilus windows having an overlapping area with the second being 'on top' of the first one (see attached screenshot), the app [highlight=]always[/highlight] selects the first as shown by the console's output:

Code: Select all

DesktopWindow:  Name=Gambas     VisibleName=Gambas      Hex(i)=3800007
.Id=58720263    Left=32 Top=10  Width=936       Height=596
DesktopWindow:  Name=Temporary  VisibleName=Temporary   Hex(i)=380E68B
.Id=58779275    Left=70 Top=338 Width=861       Height=596
DesktopWindow:  Name=FSelectWindow.class - SelectWindow-CO-JR 0.0.31 - Gambas 3 VisibleName=FSelect
Window.class - SelectWindow-CO-JR 0.0.31 - Gambas 3     Hex(i)=420000E
.Id=69206030    Left=950        Top=114 Width=944       Height=864
Selected Window: Name=Gambas, VisibleName=Gambas
Geometry=32, 10, 936, 596
Obviously I've miscommunicated what I want. I want, when the user selects an overlapping area, the app to select the window which is 'on top'. The above coding you quoted selects the first window found by the app's FindWindow method. This is why I wondered if the Shaded property could be used. Running wmctrl (in Terminal) doesn't explain the Shaded property. Even if the Shaded property determines if a window is partially overlapped, the app would still have to determine if the user clicked inside the overlapping area or in the window not on top! It looks like each window will have to be examined against the other windows to see if there is an overlap which the user has clicked on. More complexity!
I looked up wmctrl (as the 'man wmctrl' is limited in its info). At https://www.freedesktop.org/wiki/Software/wmctrl/ it shows:
Use the currently active window for the action.
* wmctrl -b toggle,shaded -r :ACTIVE:
So ACTIVE might be useful though Shaded perhaps is not. My gut feeling is that wmctrl usage is a red herring and I will have to make the Gambas coding more complex as I indicated earlier.

A minor point. Your If statement above is very long. I dislike long coding lines and prefer to split them over multiple lines. In VB it used to be possible to split a coding command over 2 lines by use of the _ character (a space or more) at the end of a line. I've tried this in Gambas but the compiler rejects it. I've looked in the Gambas books you referred to previously as well as the Gambas wiki and haven't found any mention of it. Do you know how to split a coding line (n this case, apart from having another If to replace the And)?

BTW what is the significance of 20 pixels in your coding (e.g. is it the height of the Title bar of a window)?
Attachments
Overlapping Area Screenshot.png
Overlapping Area Screenshot.png (215.67 KiB) Viewed 484 times
John

User avatar
cogier
Site Admin
Posts: 466
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Wednesday 27th May 2020 5:28pm

Hi John,
Do you find the same problem with Gambas Farm as I do: namely the slow response when scrolling down the app details after a search with no parameters set?
Have a look at my internet speed here then how the Farm looks on my computer here
Your If statement above is very long
I can't split that line as far as I know. You can split strings though.
Public Sub Form_Open()

  Print "Hello " & "Hello " &
    "Hello " & "Hello "

End
BTW what is the significance of 20 pixels in your coding (e.g. is it the height of the Title bar of a window)?
Yes I found that if I clicked in the Title bar I did not get the 'click' so the '20' allows for that.
Obviously I've miscommunicated what I want. I want, when the user selects an overlapping area, the app to select the window which is 'on top'.
I find this a strange 'want'. I 'want' the window I clicked on and NOT the one that's on top of it. Have a look here. Check out a program like Shutter it does it this way.

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Wednesday 27th May 2020 8:54pm

My question:
Obviously I've miscommunicated what I want. I want, when the user selects an overlapping area, the app to select the window which is 'on top'.
Your reply:
I find this a strange 'want'. I 'want' the window I clicked on and NOT the one that's on top of it. Have a look here. Check out a program like Shutter it does it this way.
In the attached partial screenshot, the Temporary window partially covers the Gambas window. As the Gambas desktop window is returned before the Temporary desktop window when the FindWindow method is invoked in the Form_Open event of the FSelectWindow form, this means that the Gambas desktop window will be stored before the Temporary in the aWindow array. Thus, the first desktop window in the aWindow array (found by the coding for the MouseUp event), when the user clicks on the overlapping area (so that the position of the mouse will be in both windows), will be the Gambas desktop window: this will be the selected window. I want the Temporary desktop window to be the selected window as it's on top of the Gambas desktop window. Obviously I still want the Gambas window to be the selected window when the user clicks on any point in it outside the overlapping area. From the user's point of view, this seems to me to be the logical behaviour of the app.
Attachments
Overlapping Area Screenshot.png
Overlapping Area Screenshot.png (215.67 KiB) Viewed 469 times
John

User avatar
cogier
Site Admin
Posts: 466
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Thursday 28th May 2020 6:13pm

Hi John and all,

I have not had a lot of time in the last 3 days as I have been having Forklift training!

I think I have managed to get this to work as you expect. Have a look at the SelectWindow.class. There is still one problem, if a program is opened while ScreenShot is open and you click on it to get an image, it does not work. I think I need to work out how to use DesktopWindow.refresh() anyone......
ScreenShot-1.0.7.tar.gz
(14.29 KiB) Downloaded 10 times

johnaaronrose
Posts: 22
Joined: Saturday 21st July 2018 12:13pm
Location: Wolverhampton

Re: ScreenShot

Post by johnaaronrose » Tuesday 02nd June 2020 11:45am

Hi Charlie,

I hope that you enjoyed your forklift training. The only time that I drove a forklift (without training but on order of foreman in a vacation job when I was a student and I hadn't even taken any car driving lessons let alone passed a driving test!) I drove it into a masonry column. Luckily, no damage to masonry column, forklift and (more importantly) to me, due to low speed!
Your Screenshot app needs a lot more code e.g. to process the SelectWindow class in its Form_Open into an array of Window Ids in Descending priority order, to check each DesktopWindow against the array of Window Ids & the mouse click to be in it in the Mouse_Up event. I've almost got SelectWindow app working with that code included.
Public Sub Form_Open()

Code: Select all

 Dim i As Integer
  Dim hDesktopWindow As DesktopWindow
  Dim sTest As String
  Dim sWinIds As String
  Inc Application.Busy
  ' https://unix.stackexchange.com/questions/567037/what-linux-command-will-tell-me-where-a-window-is-in-terms-of-the-z-axis-compare
  Shell "xprop -root | grep '_NET_CLIENT_LIST_STACKING(WINDOW)'" To sTest
  ' Put each X11 Window Id 
  ' after stripping off comma & space separation characters
  ' from a string, returned by above xprop command, containing a list (in ascending priority order)
  ' into the aWinId array
  Print sTest
  sWinIds = Mid$(sTest, 48)
  Print sWinIds
  aWinId = Split(sWinIds, ",", "\n", True, False)
  Print "Split"
  For i = 0 To aWinId.Max
    sTest = aWinId[i]
    aWinId[i] = Mid(Trim(sTest), 3)
    Print aWinId[i]
  Next
  aWinId.Reverse
  Print "Reverse"
  For i = 0 To aWinId.Max
    Print aWinId[i]
  Next
  aWindow = []
  iWindowLeft = 0
  iWindowTop = 0
  iWindowWidth = 0
  iWindowHeight = 0
  ' Creates aWindow array of DesktopWindow objects
  For Each i In Desktop.FindWindow(Null, Null, Null)
    hDesktopWindow = New DesktopWindow(i)
    With hDesktopWindow
      If .Minimized Then Continue
      If .VisibleName = "Desktop" And .Height = Screen.Height And .Width = Screen.Width Then Continue
      aWindow.Add(hDesktopWindow)
      If .FullScreen Then Continue
      Print "DesktopWindow: ", "Name=" & .Name, "VisibleName=" & .VisibleName
      Print "i=" & i, "Hex(i)=" & Hex(i)
      Print "Id=" & .Id, "Hex(Id)=" & Hex(.Id)
      Print "Left=" & .X, "Top=" & .Y, "Width=" & .Width, "Height=" & .Height
    End With
    FMain.PictureBoxArea.Clear
  Next
Finally
  Application.Busy = 0
Catch
  Message.Warning(ERROR.Text & " at " & ERROR.Where)
End
 
Public Sub DrawingAreaDesktop_MouseUp()
  Dim i As Integer
  Dim j As Integer
  Dim sWindowName As String
  Dim sWindowVisibleName As String
  Dim sWindowid As String
  Dim hWindow As DesktopWindow
  Dim hWindowRect As Rect
  Dim bWindowSelected As Boolean
  Dim hPicture As Picture
  Inc Application.Busy
  bWindowSelected = False
  Print "Mouse Position = " & Mouse.X & ", " & Mouse.Y
  For i = 0 To aWinId.Max
    For j = 0 To aWindow.Max
      If Hex(aWindow[j].Id) = aWinId[i] And aWindow[j].Geometry.Contains(Mouse.X, Mouse.Y) Then
        hWindow = aWindow[j]
        hWindowRect = hWindow.Geometry
        With hWindow
          sWindowName = .Name
          sWindowVisibleName = .VisibleName
          sWindowId = .Id
        End With
        With hWindowRect
          iWindowLeft = .Left
          iWindowTop = .Top
          iWindowWidth = .Width
          iWindowHeight = .Height
        End With
        bWindowSelected = True
        Break
      End If
    Next
    If bWindowSelected Then
      Print "Window Selected found in X11 Windows array"
      Break
    End If
  Next
  If bWindowSelected Then
    Print "Window Selected"
    Break
  Else
    ' Last.Lock
    Application.Busy = 0
    Message.Title = "Try again:"
    Message.Info("Did not click on window.")
    ' Last.Unlock
    Return
  End If
  Print "You have selected this window:"
  Print "Name=" & sWindowName, "VisibleName=" & sWindowVisibleName, "Id=" & sWindowId, "Hex(Id)=" & Hex(sWindowId)
  Print "Left=" & iWindowLeft, "Top=" & iWindowTop, "Width=" & iWindowWidth, "Height=" & iWindowHeight
  Last.Clear
  Paint.Begin(Last)
  Paint.LineWidth = 5
  Paint.Rectangle(iWindowLeft, iWindowTop, iWindowWidth, iWindowHeight)
  Paint.Stroke
  Paint.End
  Wait 3
  Me.Hide 'Hide the Form
  Wait 0.25 'Wait a little or you will get an opaque image
  hPicture = Desktop.Screenshot(iWindowLeft, iWindowTop, iWindowWidth, iWindowHeight) 'ScreenShot of Selected Window
  With FMain
    .PictureBoxArea.Picture = hPicture 'Add Picture to PictureBoxArea on FMain form
    .iRegionLeft = iWindowLeft
    .iRegionTop = iWindowTop
    .iRegionWidth = iWindowWidth
    .iRegionHeight = iWindowHeight
  End With
  Me.Close
Finally
  Application.Busy = 0
Catch
  Message.Warning(ERROR.Text & " at " & ERROR.Where)
End
I have a question: I wanted to use the Lock method on Last (i.e. DrawingAreaDesktop object) to stop a click on the Ok button (generated by the Message.Title = "Try again:" & Message.Info("Did not click on window.") code as shown below, in order to stop the Mouse_Up event being executed again by the user clicking Ok in the Message Box. The code compiles Ok, but gives a runtime error about duplicate window (i.e. the Message Box) as the code or Mouse_Up event is executed due to clicking on the Ok button in the Message's window. How do I correct the Lock statement?

Code: Select all

  If bWindowSelected Then
    Print "Window Selected"
  Else
    Last.Lock
    Application.Busy = 0
    Message.Title = "Try again:"
    Message.Info("Did not click on window.")
    Last.Unlock
    Return
  End If
John

User avatar
cogier
Site Admin
Posts: 466
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ScreenShot

Post by cogier » Tuesday 02nd June 2020 4:15pm

Hi John,

Yes I past the forklift training, not bad for a pensioner.

Regarding the 'Lock' situation I think you have the wrong idea about this. Have a look here.

After some experimentation we found that the 'Last' is not changed by the 'Message Box' so you don't need the 'Lock' anyway, try the code below. If you did need to store the 'Last' just create a variable to store it in.
(As mentioned before the window below is created with the 'gb' button not the '</>' code button)
Public Sub Button1_Click()

   Message.Info("Did not click on window.")
  Print Last.name

End
The 'DrawingArea1_MouseUp' routine will not get called again as the MessageBox is not the 'DrawingArea'.

There is a 'Break' in your code that is not inside a loop. This generates an error.

I noticed this 'aWindow = []' code. You don't need this, if you set up your Array with Dim aWindow as New Window it will be set up as a Dynamic array.

Post Reply